From: Mathieu Malaterre Date: Thu, 30 Jan 2025 10:42:13 +0000 (+0100) Subject: d/patches: Refresh patches X-Git-Tag: archive/raspbian/3.6.9-4+rpi1^2~24 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=366ed55636c583aa007eef5aaf8dedc82cf98467;p=dcmtk.git d/patches: Refresh patches --- diff --git a/debian/dcmtk.install b/debian/dcmtk.install index 3867465e..03a21b41 100644 --- a/debian/dcmtk.install +++ b/debian/dcmtk.install @@ -1,8 +1,8 @@ etc/dcmtk/* usr/bin/* -usr/share/dcmtk/*.css -usr/share/dcmtk/*.dump -usr/share/dcmtk/*.lut -usr/share/dcmtk/dcm2xml.dtd -usr/share/dcmtk/dsr2xml.xsd -usr/share/dcmtk/dumppat.txt +usr/share/dcmtk-3.6.9/*.css +usr/share/dcmtk-3.6.9/*.dump +usr/share/dcmtk-3.6.9/*.lut +usr/share/dcmtk-3.6.9/dcm2xml.dtd +usr/share/dcmtk-3.6.9/dsr2xml.xsd +usr/share/dcmtk-3.6.9/dumppat.txt diff --git a/debian/patches/0001-Fixed-unchecked-typecasts-of-DcmItem-search-results.patch b/debian/patches/0001-Fixed-unchecked-typecasts-of-DcmItem-search-results.patch deleted file mode 100644 index 774af83e..00000000 --- a/debian/patches/0001-Fixed-unchecked-typecasts-of-DcmItem-search-results.patch +++ /dev/null @@ -1,1662 +0,0 @@ -From dc6a2446dc03c9db90f82ce17a597f2cd53776c5 Mon Sep 17 00:00:00 2001 -From: Marco Eichelberg -Date: Mon, 15 Apr 2024 12:12:51 +0200 -Subject: [PATCH] Fixed unchecked typecasts of DcmItem::search results. - -DcmItem::search() returns a stack of DcmObject pointers as search results. -These pointers in most instances need to be casted to DcmItem, DcmElement -or a subclass of these. In many cases, the type of the object was not -properly checked before the typecast. This could lead to segmentation faults -when invalid DICOM datasets were processed where elements had the wrong -value representation. ---- - dcmdata/apps/cda2dcm.cc | 0 - dcmdata/apps/stl2dcm.cc | 0 - dcmdata/include/dcmtk/dcmdata/dcelem.h | 7 +++- - dcmdata/include/dcmtk/dcmdata/dcencdoc.h | 0 - dcmdata/include/dcmtk/dcmdata/dcobject.h | 7 +++- - dcmdata/libsrc/dcddirif.cc | 4 +-- - dcmdata/libsrc/dcdirrec.cc | 6 ++-- - dcmdata/libsrc/dcfilefo.cc | 12 +++---- - dcmdata/libsrc/dcitem.cc | 16 ++++----- - dcmimgle/libsrc/didocu.cc | 2 +- - dcmiod/libsrc/iodutil.cc | 4 +-- - dcmjpeg/libsrc/djcodece.cc | 8 ++--- - dcmnet/apps/storescu.cc | 8 ++++- - dcmnet/libsrc/dimcmd.cc | 38 ++++++++++++--------- - dcmnet/libsrc/diutil.cc | 28 ++++++++-------- - dcmnet/libsrc/dstorscu.cc | 2 +- - dcmpstat/apps/dcmmklut.cc | 6 ++-- - dcmpstat/apps/dcmpschk.cc | 8 +++-- - dcmpstat/libsrc/dviface.cc | 10 +++--- - dcmpstat/libsrc/dvpsabl.cc | 4 +-- - dcmpstat/libsrc/dvpscu.cc | 18 +++++----- - dcmpstat/libsrc/dvpsdal.cc | 4 +-- - dcmpstat/libsrc/dvpsfs.cc | 22 ++++++------- - dcmpstat/libsrc/dvpsgal.cc | 4 +-- - dcmpstat/libsrc/dvpsgll.cc | 4 +-- - dcmpstat/libsrc/dvpsgrl.cc | 4 +-- - dcmpstat/libsrc/dvpshlp.cc | 2 +- - dcmpstat/libsrc/dvpsib.cc | 42 ++++++++++++------------ - dcmpstat/libsrc/dvpsibl.cc | 4 +-- - dcmpstat/libsrc/dvpspll.cc | 4 +-- - dcmpstat/libsrc/dvpsril.cc | 4 +-- - dcmpstat/libsrc/dvpsrsl.cc | 4 +-- - dcmpstat/libsrc/dvpssp.cc | 40 +++++++++++----------- - dcmpstat/libsrc/dvpstxl.cc | 4 +-- - dcmpstat/libsrc/dvpsvll.cc | 4 +-- - dcmrt/libsrc/drttypes.cc | 8 ++--- - dcmsign/libsrc/dcsignat.cc | 22 ++++++------- - dcmsign/libsrc/sicert.cc | 4 +-- - dcmsr/libsrc/dsrtypes.cc | 6 ++-- - 39 files changed, 199 insertions(+), 175 deletions(-) - mode change 100755 => 100644 dcmdata/apps/cda2dcm.cc - mode change 100755 => 100644 dcmdata/apps/stl2dcm.cc - mode change 100755 => 100644 dcmdata/include/dcmtk/dcmdata/dcencdoc.h - -diff --git a/dcmdata/apps/cda2dcm.cc b/dcmdata/apps/cda2dcm.cc -old mode 100755 -new mode 100644 -diff --git a/dcmdata/apps/stl2dcm.cc b/dcmdata/apps/stl2dcm.cc -old mode 100755 -new mode 100644 -diff --git a/dcmdata/include/dcmtk/dcmdata/dcelem.h b/dcmdata/include/dcmtk/dcmdata/dcelem.h -index b6ffeb7eb0..2978e96180 100644 ---- a/dcmdata/include/dcmtk/dcmdata/dcelem.h -+++ b/dcmdata/include/dcmtk/dcmdata/dcelem.h -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2023, OFFIS e.V. -+ * Copyright (C) 1994-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -144,6 +144,11 @@ class DCMTK_DCMDATA_EXPORT DcmElement - */ - virtual OFBool isLeaf() const { return OFTrue; } - -+ /** check if this element can be safely casted to DcmElement -+ * @return true if DcmElement, false otherwise -+ */ -+ virtual OFBool isElement() const { return OFTrue; } -+ - /** check if value of this element is loaded into main memory - * @return true if value is present in memory, false if value still resides in file - */ -diff --git a/dcmdata/include/dcmtk/dcmdata/dcencdoc.h b/dcmdata/include/dcmtk/dcmdata/dcencdoc.h -old mode 100755 -new mode 100644 -diff --git a/dcmdata/include/dcmtk/dcmdata/dcobject.h b/dcmdata/include/dcmtk/dcmdata/dcobject.h -index 60490f6bc8..714520bcf5 100644 ---- a/dcmdata/include/dcmtk/dcmdata/dcobject.h -+++ b/dcmdata/include/dcmtk/dcmdata/dcobject.h -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2020, OFFIS e.V. -+ * Copyright (C) 1994-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -308,6 +308,11 @@ class DCMTK_DCMDATA_EXPORT DcmObject - */ - virtual OFBool isLeaf() const = 0; - -+ /** check if this element can be safely casted to DcmElement -+ * @return true if DcmElement, false otherwise -+ */ -+ virtual OFBool isElement() const { return OFFalse; } -+ - /** check if this element is nested in a sequence of items, i.e.\ not a - * top-level or stand-alone element - * @return true if this element is nested, false otherwise -diff --git a/dcmdata/libsrc/dcddirif.cc b/dcmdata/libsrc/dcddirif.cc -index a0aec59b96..69d0993e5f 100644 ---- a/dcmdata/libsrc/dcddirif.cc -+++ b/dcmdata/libsrc/dcddirif.cc -@@ -433,7 +433,7 @@ static OFBool compareItems(DcmItem *item1, - OFBool first = OFTrue; - DcmStack stack1, stack2; - /* check whether attributes are equal */ -- while (item1->nextObject(stack1, first).good() && item2->nextObject(stack2, first).good()) -+ while (item1->nextObject(stack1, first).good() && item2->nextObject(stack2, first).good() && stack1.top()->isElement() && stack2.top()->isElement()) - { - if (!compareAttributes(OFstatic_cast(DcmElement *, stack1.top()), OFstatic_cast(DcmElement *, stack2.top()), fromSequence, i++, reason)) - break; -@@ -5457,7 +5457,7 @@ OFBool DicomDirInterface::warnAboutInconsistentAttributes(DcmDirectoryRecord *re - OFBool first = OFTrue; - DcmElement *delem = NULL; - /* iterate over all record elements */ -- while (record->nextObject(stack, first).good() && (result || !abortCheck)) -+ while (record->nextObject(stack, first).good() && (result || !abortCheck) && stack.top()->isElement()) - { - delem = OFstatic_cast(DcmElement *, stack.top()); - if ((delem != NULL) && (delem->getLength() > 0)) -diff --git a/dcmdata/libsrc/dcdirrec.cc b/dcmdata/libsrc/dcdirrec.cc -index a6a2fc4858..c374c34742 100644 ---- a/dcmdata/libsrc/dcdirrec.cc -+++ b/dcmdata/libsrc/dcdirrec.cc -@@ -998,7 +998,7 @@ OFCondition DcmDirectoryRecord::fillElementsAndReadSOP(const char *referencedFil - DCMDATA_ERROR("Internal ERROR in DcmDirectoryRecord::fillElementsAndReadSOP()"); - } - uiP = new DcmUniqueIdentifier(refSOPClassTag); // (0004,1510) -- if (refFile->search(DCM_SOPClassUID, stack).good()) -+ if (refFile->search(DCM_SOPClassUID, stack).good() && (stack.top()->ident() == EVR_UI)) - { - char *uid = NULL; - OFstatic_cast(DcmUniqueIdentifier *, stack.top())->getString(uid); -@@ -1011,7 +1011,7 @@ OFCondition DcmDirectoryRecord::fillElementsAndReadSOP(const char *referencedFil - insert(uiP, OFTrue); - - uiP = new DcmUniqueIdentifier(refSOPInstTag); // (0004,1511) -- if (refFile->search(DCM_SOPInstanceUID, stack).good() || refFile->search(DCM_MediaStorageSOPInstanceUID, stack).good()) -+ if ((refFile->search(DCM_SOPInstanceUID, stack).good() || refFile->search(DCM_MediaStorageSOPInstanceUID, stack).good()) && (stack.top()->ident() == EVR_UI)) - { - char *uid = NULL; - OFstatic_cast(DcmUniqueIdentifier *, stack.top())->getString(uid); -@@ -1024,7 +1024,7 @@ OFCondition DcmDirectoryRecord::fillElementsAndReadSOP(const char *referencedFil - insert(uiP, OFTrue); - - uiP = new DcmUniqueIdentifier(refFileXferTag); // (0004,1512) -- if (refFile->search(DCM_TransferSyntaxUID, stack).good()) -+ if (refFile->search(DCM_TransferSyntaxUID, stack).good() && (stack.top()->ident() == EVR_UI)) - { - char *uid = NULL; - OFstatic_cast(DcmUniqueIdentifier *, stack.top())->getString(uid); -diff --git a/dcmdata/libsrc/dcfilefo.cc b/dcmdata/libsrc/dcfilefo.cc -index 4f72dee83d..5771e604cc 100644 ---- a/dcmdata/libsrc/dcfilefo.cc -+++ b/dcmdata/libsrc/dcfilefo.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2022, OFFIS e.V. -+ * Copyright (C) 1994-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -362,7 +362,7 @@ OFCondition DcmFileFormat::checkMetaHeaderValue(DcmMetaInfo *metainfo, - { - if ((writeMode == EWM_updateMeta) || (elem->getLength() == 0)) - { -- if (dataset->search(DCM_SOPClassUID, stack).good()) -+ if (dataset->search(DCM_SOPClassUID, stack).good() && (stack.top()->ident() == EVR_UI)) - { - char *uid = NULL; - l_error = OFstatic_cast(DcmUniqueIdentifier *, stack.top())->getString(uid); -@@ -378,7 +378,7 @@ OFCondition DcmFileFormat::checkMetaHeaderValue(DcmMetaInfo *metainfo, - else if (DCM_dcmdataLogger.isEnabledFor(OFLogger::WARN_LOG_LEVEL)) - { - // check whether UID in meta-header is identical to the one in the dataset -- if (dataset->search(DCM_SOPClassUID, stack).good()) -+ if (dataset->search(DCM_SOPClassUID, stack).good() && (stack.top()->ident() == EVR_UI)) - { - OFString uidDataset, uidMetaHeader; - OFstatic_cast(DcmUniqueIdentifier *, stack.top())->getOFStringArray(uidDataset); -@@ -404,7 +404,7 @@ OFCondition DcmFileFormat::checkMetaHeaderValue(DcmMetaInfo *metainfo, - { - if ((writeMode == EWM_updateMeta) || (elem->getLength() == 0)) - { -- if (dataset->search(DCM_SOPInstanceUID, stack).good()) -+ if (dataset->search(DCM_SOPInstanceUID, stack).good() && (stack.top()->ident() == EVR_UI)) - { - char* uid = NULL; - l_error = OFstatic_cast(DcmUniqueIdentifier *, stack.top())->getString(uid); -@@ -422,7 +422,7 @@ OFCondition DcmFileFormat::checkMetaHeaderValue(DcmMetaInfo *metainfo, - else if (DCM_dcmdataLogger.isEnabledFor(OFLogger::WARN_LOG_LEVEL)) - { - // check whether UID in meta-header is identical to the one in the dataset -- if (dataset->search(DCM_SOPInstanceUID, stack).good()) -+ if (dataset->search(DCM_SOPInstanceUID, stack).good() && (stack.top()->ident() == EVR_UI)) - { - OFString uidDataset, uidMetaHeader; - OFstatic_cast(DcmUniqueIdentifier *, stack.top())->getOFStringArray(uidDataset); -@@ -633,7 +633,7 @@ E_TransferSyntax DcmFileFormat::lookForXfer(DcmMetaInfo *metainfo) - /* check whether meta header is present (and non-empty, i.e. contains elements) */ - if (metainfo && !metainfo->isEmpty()) - { -- if (metainfo->search(DCM_TransferSyntaxUID, stack).good()) -+ if (metainfo->search(DCM_TransferSyntaxUID, stack).good() && (stack.top()->ident() == EVR_UI)) - { - DcmUniqueIdentifier *xferUI = OFstatic_cast(DcmUniqueIdentifier *, stack.top()); - if (xferUI->getTag() == DCM_TransferSyntaxUID) -diff --git a/dcmdata/libsrc/dcitem.cc b/dcmdata/libsrc/dcitem.cc -index 3960fceb45..51f95d21dd 100644 ---- a/dcmdata/libsrc/dcitem.cc -+++ b/dcmdata/libsrc/dcitem.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2023, OFFIS e.V. -+ * Copyright (C) 1994-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -2332,7 +2332,7 @@ OFBool DcmItem::tagExistsWithValue(const DcmTagKey &key, - DcmStack stack; - OFBool result = OFFalse; - -- if (search(key, stack, ESM_fromHere, searchIntoSub).good()) -+ if (search(key, stack, ESM_fromHere, searchIntoSub).good() && stack.top()->isElement()) - { - DcmElement *elem = OFstatic_cast(DcmElement *, stack.top()); - if (elem != NULL) -@@ -2355,7 +2355,7 @@ OFCondition DcmItem::findAndGetElement(const DcmTagKey &tagKey, - DcmStack stack; - /* find the element */ - OFCondition status = search(tagKey, stack, ESM_fromHere, searchIntoSub); -- if (status.good()) -+ if (status.good() && stack.top()->isElement()) - { - element = OFstatic_cast(DcmElement *, stack.top()); - /* should never happen but ... */ -@@ -2990,7 +2990,7 @@ OFCondition DcmItem::findAndGetSequence(const DcmTagKey &seqTagKey, - DcmStack stack; - /* find the element */ - OFCondition status = search(seqTagKey, stack, ESM_fromHere, searchIntoSub); -- if (status.good()) -+ if (status.good() && stack.top()->isElement()) - { - DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); - /* should never happen but ... */ -@@ -3027,7 +3027,7 @@ OFCondition DcmItem::findAndGetSequenceItem(const DcmTagKey &seqTagKey, - DcmStack stack; - /* find sequence */ - OFCondition status = search(seqTagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (status.good()) -+ if (status.good() && stack.top()->isElement()) - { - /* get element */ - DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); -@@ -3089,7 +3089,7 @@ OFCondition DcmItem::findOrCreateSequenceItem(const DcmTag& seqTag, - OFCondition status = search(seqTag, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); - DcmSequenceOfItems *sequence = NULL; - /* sequence found? */ -- if (status.good()) -+ if (status.good() && stack.top()->isElement()) - { - /* get element */ - DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); -@@ -3223,7 +3223,7 @@ OFCondition DcmItem::findAndDeleteSequenceItem(const DcmTagKey &seqTagKey, - DcmStack stack; - /* find sequence */ - OFCondition status = search(seqTagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (status.good()) -+ if (status.good() && stack.top()->isElement()) - { - /* get element */ - DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); -@@ -4224,7 +4224,7 @@ OFCondition DcmItem::insertSequenceItem(const DcmTag &seqTag, - status = search(seqTag, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); - DcmSequenceOfItems *sequence = NULL; - /* sequence found? */ -- if (status.good()) -+ if (status.good() && stack.top()->isElement()) - { - /* get element */ - DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); -diff --git a/dcmimgle/libsrc/didocu.cc b/dcmimgle/libsrc/didocu.cc -index b63f77258a..efbbd69fbd 100644 ---- a/dcmimgle/libsrc/didocu.cc -+++ b/dcmimgle/libsrc/didocu.cc -@@ -217,7 +217,7 @@ DcmElement *DiDocument::search(const DcmTagKey &tag, - obj = Object; - // only search on main dataset level - if ((obj != NULL) && (obj->search(tag, stack, ESM_fromHere, OFFalse /* searchIntoSub */) == EC_Normal) && -- (stack.top()->getLength(Xfer) > 0)) -+ (stack.top()->getLength(Xfer) > 0) && stack.top()->isElement()) - { - return OFstatic_cast(DcmElement *, stack.top()); - } -diff --git a/dcmiod/libsrc/iodutil.cc b/dcmiod/libsrc/iodutil.cc -index bd3dc87913..64c985cb50 100644 ---- a/dcmiod/libsrc/iodutil.cc -+++ b/dcmiod/libsrc/iodutil.cc -@@ -43,7 +43,7 @@ OFCondition DcmIODUtil::getAndCheckElementFromDataset( - DcmStack stack; - const DcmTagKey tagKey = delem.getTag(); - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good()) -+ if (result.good() && stack.top()->isElement()) - { - /* copy object from search stack */ - result = delem.copyFrom(*stack.top()); -@@ -76,7 +76,7 @@ OFCondition DcmIODUtil::getAndCheckElementFromDataset(DcmItem& dataset, - - DcmStack stack; - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good()) -+ if (result.good() && stack.top()->isElement()) - { - /* copy object from search stack */ - delem = OFstatic_cast(DcmElement*, stack.top()->clone()); -diff --git a/dcmjpeg/libsrc/djcodece.cc b/dcmjpeg/libsrc/djcodece.cc -index 4128a20402..d0371f6c2b 100644 ---- a/dcmjpeg/libsrc/djcodece.cc -+++ b/dcmjpeg/libsrc/djcodece.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2001-2022, OFFIS e.V. -+ * Copyright (C) 2001-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -1399,17 +1399,17 @@ OFCondition DJCodecEncoder::correctVOIWindows( - DcmElement *explanation = NULL; - - DcmStack stack; -- if ((dataset->search(DCM_WindowCenter, stack, ESM_fromHere, OFFalse)).good()) -+ if ((dataset->search(DCM_WindowCenter, stack, ESM_fromHere, OFFalse)).good() && stack.top()->isElement()) - { - center = OFreinterpret_cast(DcmElement*, stack.top()); - } - stack.clear(); -- if ((dataset->search(DCM_WindowWidth, stack, ESM_fromHere, OFFalse)).good()) -+ if ((dataset->search(DCM_WindowWidth, stack, ESM_fromHere, OFFalse)).good() && stack.top()->isElement()) - { - width = OFreinterpret_cast(DcmElement*, stack.top()); - } - stack.clear(); -- if ((dataset->search(DCM_WindowCenterWidthExplanation, stack, ESM_fromHere, OFFalse)).good()) -+ if ((dataset->search(DCM_WindowCenterWidthExplanation, stack, ESM_fromHere, OFFalse)).good() && stack.top()->isElement()) - { - explanation = OFreinterpret_cast(DcmElement*, stack.top()); - } -diff --git a/dcmnet/apps/storescu.cc b/dcmnet/apps/storescu.cc -index e2c3b29395..bd7f1cd61f 100644 ---- a/dcmnet/apps/storescu.cc -+++ b/dcmnet/apps/storescu.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1996-2023, OFFIS e.V. -+ * Copyright (C) 1996-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -1138,6 +1138,12 @@ updateStringAttributeValue(DcmItem *dataset, const DcmTagKey &key, OFString &val - return OFFalse; - } - -+ if (! stack.top()->isElement()) -+ { -+ OFLOG_ERROR(storescuLogger, "updateStringAttributeValue: not a DcmElement: " << tag.getTagName() << " " << key); -+ return OFFalse; -+ } -+ - DcmElement *elem = OFstatic_cast(DcmElement *, stack.top()); - - DcmVR vr(elem->ident()); -diff --git a/dcmnet/libsrc/dimcmd.cc b/dcmnet/libsrc/dimcmd.cc -index ffd225f4b9..3bcfae5e4f 100644 ---- a/dcmnet/libsrc/dimcmd.cc -+++ b/dcmnet/libsrc/dimcmd.cc -@@ -191,14 +191,16 @@ addString(DcmDataset *obj, DcmTagKey t, char *s, OFBool keepPadding) - static OFCondition - getString(DcmDataset *obj, DcmTagKey t, char *s, int maxlen, OFBool *spacePadded) - { -- DcmElement *elem; -+ DcmElement *elem = NULL; - DcmStack stack; - OFCondition ec = EC_Normal; - char* aString; - - ec = obj->search(t, stack); -- elem = (DcmElement*)stack.top(); -- if (ec == EC_Normal && elem != NULL) { -+ if (ec.good() && stack.top()->isElement()) -+ elem = (DcmElement*)stack.top(); -+ -+ if (elem != NULL) { - if (elem->getLength() == 0) { - s[0] = '\0'; - } else if (elem->getLength() > (Uint32)maxlen) { -@@ -266,17 +268,19 @@ addUS(DcmDataset *obj, DcmTagKey t, Uint16 us) - static OFCondition - getUS(DcmDataset *obj, DcmTagKey t, Uint16 *us) - { -- DcmElement *elem; -+ DcmElement *elem = NULL; - DcmStack stack; - OFCondition ec = EC_Normal; - - ec = obj->search(t, stack); -- elem = (DcmElement*)stack.top(); -- if (ec == EC_Normal && elem != NULL) { -+ if (ec.good() && stack.top()->isElement()) -+ elem = (DcmElement*)stack.top(); -+ -+ if (elem != NULL) { - ec = elem->getUint16(*us, 0); - } - -- return (ec == EC_Normal)?(EC_Normal):(DIMSE_PARSEFAILED); -+ return (ec.good())?(EC_Normal):(DIMSE_PARSEFAILED); - } - - static OFCondition -@@ -317,17 +321,19 @@ addUL(DcmDataset *obj, DcmTagKey t, Uint32 ul) - static OFCondition - getUL(DcmDataset *obj, DcmTagKey t, Uint32 *ul) - { -- DcmElement *elem; -+ DcmElement *elem = NULL; - DcmStack stack; - OFCondition ec = EC_Normal; - - ec = obj->search(t, stack); -- elem = (DcmElement*)stack.top(); -- if (ec == EC_Normal && elem != NULL) { -+ if (ec.good() && stack.top()->isElement()) -+ elem = (DcmElement*)stack.top(); -+ -+ if (elem != NULL) { - ec = elem->getUint32(*ul, 0); - } - -- return (ec == EC_Normal)?(EC_Normal):(DIMSE_PARSEFAILED); -+ return (ec.good())?(EC_Normal):(DIMSE_PARSEFAILED); - } - - #if 0 -@@ -378,15 +384,17 @@ addAttributeList(DcmDataset *obj, DcmTagKey t, Uint16 *lst, int listCount) - static OFCondition - getAttributeList(DcmDataset *obj, DcmTagKey t, Uint16 **lst, int *listCount) - { -- DcmElement *elem; -+ DcmElement *elem = NULL; - DcmStack stack; - OFCondition ec = EC_Normal; - Uint16 *aList = NULL; - Uint32 nBytes = 0; - - ec = obj->search(t, stack); -- elem = (DcmElement*)stack.top(); -- if (ec == EC_Normal && elem != NULL) { -+ if (ec.good() && stack.top()->isElement()) -+ elem = (DcmElement*)stack.top(); -+ -+ if (elem) { - nBytes = elem->getLength(); - *listCount = (int)(nBytes / sizeof(Uint16)); - if (*listCount > 0) { -@@ -398,7 +406,7 @@ getAttributeList(DcmDataset *obj, DcmTagKey t, Uint16 **lst, int *listCount) - } - } - -- return (ec == EC_Normal)?(EC_Normal):(DIMSE_PARSEFAILED); -+ return (ec.good())?(EC_Normal):(DIMSE_PARSEFAILED); - } - - /* -diff --git a/dcmnet/libsrc/diutil.cc b/dcmnet/libsrc/diutil.cc -index 75111ae3bb..31c9645fcd 100644 ---- a/dcmnet/libsrc/diutil.cc -+++ b/dcmnet/libsrc/diutil.cc -@@ -148,23 +148,21 @@ DU_stripLeadingAndTrailingSpaces(char *s) - OFBool - DU_getStringDOElement(DcmItem *obj, DcmTagKey t, char *s, size_t bufsize) - { -- DcmByteString *elem; - DcmStack stack; -- OFCondition ec = EC_Normal; - char* aString; - -- ec = obj->search(t, stack); -- elem = (DcmByteString*) stack.top(); -- if (ec == EC_Normal && elem != NULL) { -+ OFCondition ec = obj->search(t, stack); -+ if (ec.good() && (stack.top() != NULL) && stack.top()->isElement()) { -+ DcmElement *elem = (DcmElement *) stack.top(); - if (elem->getLength() == 0) { - s[0] = '\0'; - } else { - ec = elem->getString(aString); -- if (ec == EC_Normal) -+ if (ec.good()) - OFStandard::strlcpy(s, aString, bufsize); - } - } -- return (ec == EC_Normal); -+ return (ec.good()); - } - - OFBool -@@ -182,7 +180,7 @@ DU_putStringDOElement(DcmItem *obj, DcmTagKey t, const char *s) - ec = obj->insert(e, OFTrue); - } - -- return (ec == EC_Normal); -+ return (ec.good()); - } - - OFBool -@@ -190,15 +188,15 @@ DU_getShortDOElement(DcmItem *obj, DcmTagKey t, Uint16 *us) - { - DcmElement *elem; - DcmStack stack; -- OFCondition ec = EC_Normal; - -- ec = obj->search(t, stack); -- elem = (DcmElement*) stack.top(); -- if (ec == EC_Normal && elem != NULL) { -- ec = elem->getUint16(*us, 0); -+ OFCondition ec = obj->search(t, stack); -+ if (ec.good() && stack.top()->isElement()) -+ { -+ elem = (DcmElement*) stack.top(); -+ if (elem) ec = elem->getUint16(*us, 0); - } - -- return (ec == EC_Normal); -+ return (ec.good()); - } - - OFBool -@@ -215,7 +213,7 @@ DU_putShortDOElement(DcmItem *obj, DcmTagKey t, Uint16 us) - if (ec == EC_Normal) { - ec = obj->insert(e, OFTrue); - } -- return (ec == EC_Normal); -+ return (ec.good()); - } - - OFBool -diff --git a/dcmnet/libsrc/dstorscu.cc b/dcmnet/libsrc/dstorscu.cc -index cbb3dcbe97..01024d5406 100644 ---- a/dcmnet/libsrc/dstorscu.cc -+++ b/dcmnet/libsrc/dstorscu.cc -@@ -484,7 +484,7 @@ OFCondition DcmStorageSCU::addDicomFilesFromDICOMDIR(const OFFilename &filename, - OFFilename dirName; - OFStandard::getDirNameFromPath(dirName, filename, OFFalse /* assumeDirName */); - // iterate over all items (directory records) where ReferencedFileID is present -- while (dataset->search(DCM_ReferencedFileID, stack, ESM_afterStackTop, OFTrue).good()) -+ while (dataset->search(DCM_ReferencedFileID, stack, ESM_afterStackTop, OFTrue).good() && stack.top()->isElement()) - { - // make sure that the dataset and element pointer are there - if (stack.card() > 1) -diff --git a/dcmpstat/apps/dcmmklut.cc b/dcmpstat/apps/dcmmklut.cc -index 044a17b3af..6a72ed3843 100644 ---- a/dcmpstat/apps/dcmmklut.cc -+++ b/dcmpstat/apps/dcmmklut.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2023, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -971,7 +971,7 @@ int main(int argc, char *argv[]) - { - // search existing sequence - DcmStack stack; -- if (EC_Normal == dataset->search(DCM_PresentationLUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dataset->search(DCM_PresentationLUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - dseq=(DcmSequenceOfItems *)stack.top(); - } - if (dseq == NULL) -@@ -992,7 +992,7 @@ int main(int argc, char *argv[]) - { - // search existing sequence - DcmStack stack; -- if (EC_Normal == dataset->search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dataset->search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - dseq=(DcmSequenceOfItems *)stack.top(); - } - if (dseq == NULL) -diff --git a/dcmpstat/apps/dcmpschk.cc b/dcmpstat/apps/dcmpschk.cc -index ada6b164a3..12826b23f7 100644 ---- a/dcmpstat/apps/dcmpschk.cc -+++ b/dcmpstat/apps/dcmpschk.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2000-2023, OFFIS e.V. -+ * Copyright (C) 2000-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -652,7 +652,11 @@ static OFString printAttribute( - OFOStringStream str; - - ec = dset->search(key, stack, ESM_fromHere, OFFalse); -- elem = (DcmElement*) stack.top(); -+ if (ec.good() && stack.top()->isElement()) -+ { -+ elem = (DcmElement*) stack.top(); -+ } -+ - if (elem) - elem->print(str, DCMTypes::PF_shortenLongTagValues); - else -diff --git a/dcmpstat/libsrc/dviface.cc b/dcmpstat/libsrc/dviface.cc -index 259e1580e0..d3a84510df 100644 ---- a/dcmpstat/libsrc/dviface.cc -+++ b/dcmpstat/libsrc/dviface.cc -@@ -1417,14 +1417,14 @@ OFBool DVInterface::createPStateCache() - if (reference != NULL) - { - DcmStack stack; -- if (dataset->search(DCM_ContentDescription, stack, ESM_fromHere, OFFalse) == EC_Normal) -+ if (dataset->search(DCM_ContentDescription, stack, ESM_fromHere, OFFalse) == EC_Normal && (stack.top()->ident() == EVR_LO)) - { - char *value = NULL; - if ((*OFstatic_cast(DcmLongString *, stack.top())).getString(value) == EC_Normal) - reference->Description = value; - } - stack.clear(); -- if (dataset->search(DCM_ContentLabel, stack, ESM_fromHere, OFFalse) == EC_Normal) -+ if (dataset->search(DCM_ContentLabel, stack, ESM_fromHere, OFFalse) == EC_Normal && (stack.top()->ident() == EVR_LO)) - { - char *value = NULL; - if ((*OFstatic_cast(DcmLongString *, stack.top())).getString(value) == EC_Normal) -@@ -2835,12 +2835,12 @@ OFCondition DVInterface::saveFileFormatToDB(DcmFileFormat &fileformat) - DcmDataset *dset = fileformat.getDataset(); - if (dset) - { -- if (EC_Normal == dset->search(DCM_SOPInstanceUID, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset->search(DCM_SOPInstanceUID, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - OFstatic_cast(DcmElement *, stack.top())->getString(instanceUID); - } - stack.clear(); -- if (EC_Normal == dset->search(DCM_SOPClassUID, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset->search(DCM_SOPClassUID, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - OFstatic_cast(DcmElement *, stack.top())->getString(classUID); - } -@@ -3756,7 +3756,7 @@ OFCondition DVInterface::addToPrintHardcopyFromDB(const char *studyUID, const ch - DVPSPresentationLUT presentationLUT; - if (EC_Normal != presentationLUT.read(*dataset, OFFalse)) presentationLUT.setType(DVPSP_identity); - result = dataset->search(sopclassuid.getTag(), stack, ESM_fromHere, OFFalse); -- if (EC_Normal == result) -+ if (EC_Normal == result && (stack.top()->ident() == EVR_UI)) - { - char *sopclass = NULL; - sopclassuid = *OFstatic_cast(DcmUniqueIdentifier *, stack.top()); -diff --git a/dcmpstat/libsrc/dvpsabl.cc b/dcmpstat/libsrc/dvpsabl.cc -index 62cc1d51b9..bbda18183e 100644 ---- a/dcmpstat/libsrc/dvpsabl.cc -+++ b/dcmpstat/libsrc/dvpsabl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1999-2010, OFFIS e.V. -+ * Copyright (C) 1999-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -69,7 +69,7 @@ OFCondition DVPSAnnotationContent_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_RETIRED_AnnotationContentSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_RETIRED_AnnotationContentSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpscu.cc b/dcmpstat/libsrc/dvpscu.cc -index be3c81fe04..02a19452f1 100644 ---- a/dcmpstat/libsrc/dvpscu.cc -+++ b/dcmpstat/libsrc/dvpscu.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2020, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -80,14 +80,14 @@ OFCondition DVPSCurve::read(DcmItem &dset, Uint8 group) - - /* first we look for the Curve Data */ - DcmTagKey key(0x5000 + group,0x3000); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_curveData = (DcmElement *)(stack.top()); - } else return EC_IllegalCall; - - key.setElement(0x0005); // Curve Dimensions - stack.clear(); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_curveDimensions = (DcmElement *)(stack.top()); - } else return EC_IllegalCall; -@@ -101,42 +101,42 @@ OFCondition DVPSCurve::read(DcmItem &dset, Uint8 group) - - key.setElement(0x0010); // Number of Points - stack.clear(); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_numberOfPoints = (DcmElement *)(stack.top()); - } else return EC_IllegalCall; - - key.setElement(0x0020); // Type of Data - stack.clear(); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_typeOfData = (DcmElement *)(stack.top()); - } else return EC_IllegalCall; - - key.setElement(0x0103); // Data Value Representation - stack.clear(); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_dataVR = (DcmElement *)(stack.top()); - } else return EC_IllegalCall; - - key.setElement(0x0022); // Curve Description - stack.clear(); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_curveDescription = (DcmElement *)(stack.top()); - } - - key.setElement(0x0030); // Axis Units - stack.clear(); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_axisUnits = (DcmElement *)(stack.top()); - } - - key.setElement(0x2500); // Curve Label - stack.clear(); -- if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(key, stack, ESM_fromHere, OFFalse) && stack.top()->isElement()) - { - d_curveLabel = (DcmElement *)(stack.top()); - } -diff --git a/dcmpstat/libsrc/dvpsdal.cc b/dcmpstat/libsrc/dvpsdal.cc -index 519aa977fd..969c182999 100644 ---- a/dcmpstat/libsrc/dvpsdal.cc -+++ b/dcmpstat/libsrc/dvpsdal.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1999-2010, OFFIS e.V. -+ * Copyright (C) 1999-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -67,7 +67,7 @@ OFCondition DVPSDisplayedArea_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_DisplayedAreaSelectionSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_DisplayedAreaSelectionSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpsfs.cc b/dcmpstat/libsrc/dvpsfs.cc -index 5a5173c155..ba311b258e 100644 ---- a/dcmpstat/libsrc/dvpsfs.cc -+++ b/dcmpstat/libsrc/dvpsfs.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2021, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -280,7 +280,7 @@ OFBool DVPSFilmSession::printSCPCreate( - { - stack.clear(); - -- if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_SQ)) - { - DcmSequenceOfItems *seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -@@ -480,7 +480,7 @@ OFBool DVPSFilmSession::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)numberOfCopies.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)numberOfCopies.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_IS)) - { - numberOfCopies = *((DcmIntegerString *)(stack.top())); - Sint32 numCopies=0; -@@ -502,7 +502,7 @@ OFBool DVPSFilmSession::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)printPriority.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)printPriority.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - printPriority = *((DcmCodeString *)(stack.top())); - OFString aString; -@@ -523,7 +523,7 @@ OFBool DVPSFilmSession::printSCPSet( - { - Uint32 numMediumTypes = cfg.getTargetPrinterNumberOfMediumTypes(cfgname); - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)mediumType.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)mediumType.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - mediumType = *((DcmCodeString *)(stack.top())); - OFString theMedium; -@@ -555,7 +555,7 @@ OFBool DVPSFilmSession::printSCPSet( - { - Uint32 numFilmDestination = cfg.getTargetPrinterNumberOfFilmDestinations(cfgname); - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)filmDestination.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)filmDestination.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - filmDestination = *((DcmCodeString *)(stack.top())); - OFString theDestination; -@@ -586,7 +586,7 @@ OFBool DVPSFilmSession::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)filmSessionLabel.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)filmSessionLabel.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_LO)) - { - filmSessionLabel = *((DcmLongString *)(stack.top())); - ADD_TO_PDATASET(DcmLongString, filmSessionLabel) -@@ -597,7 +597,7 @@ OFBool DVPSFilmSession::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)ownerID.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)ownerID.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_SH)) - { - ownerID = *((DcmShortString *)(stack.top())); - ADD_TO_PDATASET(DcmShortString, ownerID) -@@ -611,7 +611,7 @@ OFBool DVPSFilmSession::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)illumination.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)illumination.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - illumination = *((DcmUnsignedShort *)(stack.top())); - // we don't check illumination set by the user (for now) -@@ -623,7 +623,7 @@ OFBool DVPSFilmSession::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)reflectedAmbientLight.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)reflectedAmbientLight.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - reflectedAmbientLight = *((DcmUnsignedShort *)(stack.top())); - // we don't check reflected ambient light set by the user (for now) -@@ -636,7 +636,7 @@ OFBool DVPSFilmSession::printSCPSet( - { - stack.clear(); - -- if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_SQ)) - { - DcmSequenceOfItems *seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -diff --git a/dcmpstat/libsrc/dvpsgal.cc b/dcmpstat/libsrc/dvpsgal.cc -index 909deac9e2..89d893de83 100644 ---- a/dcmpstat/libsrc/dvpsgal.cc -+++ b/dcmpstat/libsrc/dvpsgal.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2010, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -69,7 +69,7 @@ OFCondition DVPSGraphicAnnotation_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_GraphicAnnotationSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_GraphicAnnotationSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpsgll.cc b/dcmpstat/libsrc/dvpsgll.cc -index d82d208628..fbf5d97d72 100644 ---- a/dcmpstat/libsrc/dvpsgll.cc -+++ b/dcmpstat/libsrc/dvpsgll.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2017, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -75,7 +75,7 @@ OFCondition DVPSGraphicLayer_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_GraphicLayerSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_GraphicLayerSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpsgrl.cc b/dcmpstat/libsrc/dvpsgrl.cc -index 14d0e713f9..61dd6565c3 100644 ---- a/dcmpstat/libsrc/dvpsgrl.cc -+++ b/dcmpstat/libsrc/dvpsgrl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2010, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -66,7 +66,7 @@ OFCondition DVPSGraphicObject_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_GraphicObjectSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_GraphicObjectSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpshlp.cc b/dcmpstat/libsrc/dvpshlp.cc -index 20b4429e45..fd1057a137 100644 ---- a/dcmpstat/libsrc/dvpshlp.cc -+++ b/dcmpstat/libsrc/dvpshlp.cc -@@ -163,7 +163,7 @@ OFBool DVPSHelper::haveReferencedUIDItem(DcmSequenceOfItems& seq, const char *ui - { - item = seq.getItem(i); - stack.clear(); -- if (EC_Normal == item->search(DCM_ReferencedSOPClassUID, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == item->search(DCM_ReferencedSOPClassUID, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_UI)) - { - aString.clear(); - refuid = (DcmUniqueIdentifier *)(stack.top()); -diff --git a/dcmpstat/libsrc/dvpsib.cc b/dcmpstat/libsrc/dvpsib.cc -index 096c5b3e19..57fee5763b 100644 ---- a/dcmpstat/libsrc/dvpsib.cc -+++ b/dcmpstat/libsrc/dvpsib.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2018, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -153,7 +153,7 @@ OFCondition DVPSImageBoxContent::read(DcmItem &dset, DVPSPresentationLUT_PList& - if (result==EC_Normal) - { - stack.clear(); -- if (EC_Normal == dset.search(DCM_ReferencedImageSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_ReferencedImageSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -@@ -181,7 +181,7 @@ OFCondition DVPSImageBoxContent::read(DcmItem &dset, DVPSPresentationLUT_PList& - // check referenced presentation LUT sequence - // if there is any reference, it must refer to one of the presentation LUTs we are managing. - stack.clear(); -- if (EC_Normal == dset.search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -@@ -672,7 +672,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)imageBoxPosition.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)imageBoxPosition.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - imageBoxPosition = *((DcmUnsignedShort *)(stack.top())); - // the image box position is checked elsewhere -@@ -688,7 +688,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)magnificationType.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)magnificationType.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - magnificationType = *((DcmCodeString *)(stack.top())); - Uint32 numMagnifications = cfg.getTargetPrinterNumberOfMagnificationTypes(cfgname); -@@ -721,7 +721,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - { - - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)smoothingType.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)smoothingType.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - smoothingType = *((DcmCodeString *)(stack.top())); - Uint32 numSmoothings = cfg.getTargetPrinterNumberOfSmoothingTypes(cfgname); -@@ -761,7 +761,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)configurationInformation.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)configurationInformation.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_ST)) - { - configurationInformation = *((DcmShortText *)(stack.top())); - Uint32 numConfigurationInformation = cfg.getTargetPrinterNumberOfConfigurationSettings(cfgname); -@@ -800,7 +800,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)polarity.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)polarity.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - polarity = *((DcmCodeString *)(stack.top())); - OFString thePolarity; -@@ -820,7 +820,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)requestedImageSize.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)requestedImageSize.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_DS)) - { - if (! cfg.getTargetPrinterSupportsRequestedImageSize(cfgname)) - { -@@ -841,7 +841,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)requestedDecimateCropBehavior.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)requestedDecimateCropBehavior.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - if (! cfg.getTargetPrinterSupportsDecimateCrop(cfgname)) - { -@@ -871,7 +871,7 @@ OFBool DVPSImageBoxContent::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search(DCM_BasicGrayscaleImageSequence, stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search(DCM_BasicGrayscaleImageSequence, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_SQ)) - { - DcmSequenceOfItems *seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -@@ -971,7 +971,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)samplesPerPixel.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)samplesPerPixel.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - samplesPerPixel = *((DcmUnsignedShort *)(stack.top())); - val = 0; -@@ -994,7 +994,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)rows.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)rows.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - rows = *((DcmUnsignedShort *)(stack.top())); - val = 0; -@@ -1017,7 +1017,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)columns.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)columns.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - columns = *((DcmUnsignedShort *)(stack.top())); - val = 0; -@@ -1042,7 +1042,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)bitsStored.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)bitsStored.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - bitsStored = *((DcmUnsignedShort *)(stack.top())); - val = 0; -@@ -1082,7 +1082,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)bitsAllocated.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)bitsAllocated.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - bitsAllocated = *((DcmUnsignedShort *)(stack.top())); - val = 0; -@@ -1105,7 +1105,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)highBit.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)highBit.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - highBit = *((DcmUnsignedShort *)(stack.top())); - val = 0; -@@ -1128,7 +1128,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)pixelRepresentation.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)pixelRepresentation.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - pixelRepresentation = *((DcmUnsignedShort *)(stack.top())); - val = 0; -@@ -1151,7 +1151,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)photometricInterpretation.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)photometricInterpretation.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - photometricInterpretation = *((DcmCodeString *)(stack.top())); - OFString theColorModel; -@@ -1175,7 +1175,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)pixelAspectRatio.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)pixelAspectRatio.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_IS)) - { - pixelAspectRatio = *((DcmIntegerString *)(stack.top())); - if (pixelAspectRatio.getVM() != 2) -@@ -1193,7 +1193,7 @@ OFBool DVPSImageBoxContent::printSCPEvaluateBasicGrayscaleImageSequence( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search(DCM_PixelData, stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search(DCM_PixelData, stack, ESM_fromHere, OFFalse)) && stack.top()->isElement()) - { - pixelData = new DcmPixelData(DCM_PixelData); - if (pixelData) -diff --git a/dcmpstat/libsrc/dvpsibl.cc b/dcmpstat/libsrc/dvpsibl.cc -index e3768d5a0d..ef069eb845 100644 ---- a/dcmpstat/libsrc/dvpsibl.cc -+++ b/dcmpstat/libsrc/dvpsibl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1999-2010, OFFIS e.V. -+ * Copyright (C) 1999-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -68,7 +68,7 @@ OFCondition DVPSImageBoxContent_PList::read(DcmItem &dset, DVPSPresentationLUT_P - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_RETIRED_ImageBoxContentSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_RETIRED_ImageBoxContentSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpspll.cc b/dcmpstat/libsrc/dvpspll.cc -index 1b2b7a35bb..46465171c7 100644 ---- a/dcmpstat/libsrc/dvpspll.cc -+++ b/dcmpstat/libsrc/dvpspll.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1999-2022, OFFIS e.V. -+ * Copyright (C) 1999-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -72,7 +72,7 @@ OFCondition DVPSPresentationLUT_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_RETIRED_PresentationLUTContentSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_RETIRED_PresentationLUTContentSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpsril.cc b/dcmpstat/libsrc/dvpsril.cc -index 793e69063a..9dee1f6bfd 100644 ---- a/dcmpstat/libsrc/dvpsril.cc -+++ b/dcmpstat/libsrc/dvpsril.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2022, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -71,7 +71,7 @@ OFCondition DVPSReferencedImage_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_ReferencedImageSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_ReferencedImageSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpsrsl.cc b/dcmpstat/libsrc/dvpsrsl.cc -index 4b0c83aa75..d2f9dcfffd 100644 ---- a/dcmpstat/libsrc/dvpsrsl.cc -+++ b/dcmpstat/libsrc/dvpsrsl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2010, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -69,7 +69,7 @@ OFCondition DVPSReferencedSeries_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_ReferencedSeriesSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_ReferencedSeriesSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpssp.cc b/dcmpstat/libsrc/dvpssp.cc -index 98b1201a7f..717c814607 100644 ---- a/dcmpstat/libsrc/dvpssp.cc -+++ b/dcmpstat/libsrc/dvpssp.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2021, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -328,7 +328,7 @@ OFCondition DVPSStoredPrint::read(DcmItem &dset) - if (result==EC_Normal) - { - stack.clear(); -- if (EC_Normal == dset.search(DCM_RETIRED_FilmBoxContentSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_RETIRED_FilmBoxContentSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -@@ -362,7 +362,7 @@ OFCondition DVPSStoredPrint::read(DcmItem &dset) - // check referenced presentation LUT sequence - // if there is any reference, it must refer to one of the presentation LUTs we are managing. - stack.clear(); -- if (EC_Normal == item->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == item->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -@@ -445,7 +445,7 @@ OFCondition DVPSStoredPrint::read(DcmItem &dset) - if (result==EC_Normal) - { - stack.clear(); -- if (EC_Normal == dset.search(DCM_RETIRED_PrintManagementCapabilitiesSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_RETIRED_PrintManagementCapabilitiesSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - OFBool haveFilmBox = OFFalse; - OFBool haveGrayscaleImageBox = OFFalse; -@@ -511,7 +511,7 @@ OFCondition DVPSStoredPrint::read(DcmItem &dset) - destination.clear(); - printerName.clear(); - stack.clear(); -- if (EC_Normal == dset.search(DCM_RETIRED_PrinterCharacteristicsSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_RETIRED_PrinterCharacteristicsSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq = (DcmSequenceOfItems *)stack.top(); - if (seq->card() > 0) -@@ -1536,7 +1536,7 @@ OFCondition DVPSStoredPrint::printSCUcreateBasicFilmBox(DVPSPrintMessageHandler& - { - // N-CREATE was successful, now evaluate Referenced Image Box SQ - stack.clear(); -- if (EC_Normal == attributeListOut->search(DCM_ReferencedImageBoxSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == attributeListOut->search(DCM_ReferencedImageBoxSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - numItems = (size_t)seq->card(); -@@ -1559,7 +1559,7 @@ OFCondition DVPSStoredPrint::printSCUcreateBasicFilmBox(DVPSPrintMessageHandler& - // evaluate Referenced Basic Annotation Box SQ if present - stack.clear(); - annotationContentList.clearAnnotationSOPInstanceUIDs(); -- if (EC_Normal == attributeListOut->search(DCM_ReferencedBasicAnnotationBoxSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == attributeListOut->search(DCM_ReferencedBasicAnnotationBoxSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - numItems = (size_t)seq->card(); -@@ -2419,7 +2419,7 @@ OFBool DVPSStoredPrint::printSCPCreate( - { - stack.clear(); - -- if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_SQ)) - { - DcmSequenceOfItems *seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -@@ -2487,7 +2487,7 @@ OFBool DVPSStoredPrint::printSCPCreate( - { - stack.clear(); - -- if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedFilmSessionSequence, stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedFilmSessionSequence, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_SQ)) - { - DcmUniqueIdentifier classUID(DCM_ReferencedSOPClassUID); - DcmUniqueIdentifier instanceUID(DCM_ReferencedSOPInstanceUID); -@@ -2706,7 +2706,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)magnificationType.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)magnificationType.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - magnificationType = *((DcmCodeString *)(stack.top())); - Uint32 numMagnifications = cfg.getTargetPrinterNumberOfMagnificationTypes(cfgname); -@@ -2739,7 +2739,7 @@ OFBool DVPSStoredPrint::printSCPSet( - { - - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)smoothingType.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)smoothingType.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - smoothingType = *((DcmCodeString *)(stack.top())); - Uint32 numSmoothings = cfg.getTargetPrinterNumberOfSmoothingTypes(cfgname); -@@ -2781,7 +2781,7 @@ OFBool DVPSStoredPrint::printSCPSet( - { - - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)borderDensity.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)borderDensity.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - borderDensity = *((DcmCodeString *)(stack.top())); - Uint32 numBorderDensities = cfg.getTargetPrinterNumberOfBorderDensities(cfgname); -@@ -2832,7 +2832,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)emptyImageDensity.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)emptyImageDensity.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - emptyImageDensity = *((DcmCodeString *)(stack.top())); - Uint32 numEmptyImageDensities = cfg.getTargetPrinterNumberOfEmptyImageDensities(cfgname); -@@ -2883,7 +2883,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)maxDensity.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)maxDensity.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - maxDensity = *((DcmUnsignedShort *)(stack.top())); - // we don't check a max density set by the user (for now) -@@ -2895,7 +2895,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)minDensity.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)minDensity.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - minDensity = *((DcmUnsignedShort *)(stack.top())); - Uint32 numMinDensities = cfg.getTargetPrinterNumberOfMinDensities(cfgname); -@@ -2917,7 +2917,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)trim.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)trim.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_CS)) - { - trim = *((DcmCodeString *)(stack.top())); - -@@ -2945,7 +2945,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)configurationInformation.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)configurationInformation.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_ST)) - { - configurationInformation = *((DcmShortText *)(stack.top())); - Uint32 numConfigurationInformation = cfg.getTargetPrinterNumberOfConfigurationSettings(cfgname); -@@ -2987,7 +2987,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)illumination.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)illumination.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - illumination = *((DcmUnsignedShort *)(stack.top())); - // we don't check illumination set by the user (for now) -@@ -2999,7 +2999,7 @@ OFBool DVPSStoredPrint::printSCPSet( - if (result) - { - stack.clear(); -- if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)reflectedAmbientLight.getTag(), stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search((DcmTagKey &)reflectedAmbientLight.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) - { - reflectedAmbientLight = *((DcmUnsignedShort *)(stack.top())); - // we don't check reflected ambient light set by the user (for now) -@@ -3012,7 +3012,7 @@ OFBool DVPSStoredPrint::printSCPSet( - { - stack.clear(); - -- if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse))) -+ if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_SQ)) - { - DcmSequenceOfItems *seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) -diff --git a/dcmpstat/libsrc/dvpstxl.cc b/dcmpstat/libsrc/dvpstxl.cc -index ffb6dcc10e..8e35ff7ae6 100644 ---- a/dcmpstat/libsrc/dvpstxl.cc -+++ b/dcmpstat/libsrc/dvpstxl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2010, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -66,7 +66,7 @@ OFCondition DVPSTextObject_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_TextObjectSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_TextObjectSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmpstat/libsrc/dvpsvll.cc b/dcmpstat/libsrc/dvpsvll.cc -index 3859f4ab96..17a6277071 100644 ---- a/dcmpstat/libsrc/dvpsvll.cc -+++ b/dcmpstat/libsrc/dvpsvll.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2010, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -66,7 +66,7 @@ OFCondition DVPSVOILUT_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -diff --git a/dcmrt/libsrc/drttypes.cc b/dcmrt/libsrc/drttypes.cc -index 3aee4312f2..77ff1674c6 100644 ---- a/dcmrt/libsrc/drttypes.cc -+++ b/dcmrt/libsrc/drttypes.cc -@@ -1,14 +1,12 @@ - /* - * -- * Copyright (c) 2008-2021, OFFIS e.V. and ICSMED AG, Oldenburg, Germany -- * Copyright (C) 2013-2021, J. Riesmeier, Oldenburg, Germany -+ * Copyright (c) 2008-2024, OFFIS e.V. and ICSMED AG, Oldenburg, Germany -+ * Copyright (C) 2013-2024, J. Riesmeier, Oldenburg, Germany - * All rights reserved. See COPYRIGHT file for details. - * - * Source file for class DRTTypes - * - * Generated manually based on dsrtypes.cc -- * File created on 2008-12-05 -- * Last modified on 2016-02-12 by Riesmeier - * - */ - -@@ -212,7 +210,7 @@ OFCondition DRTTypes::getAndCheckStringValueFromDataset(DcmItem &dataset, - { - DcmStack stack; - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good()) -+ if (result.good() && stack.top()->isElement()) - { - DcmElement *element = OFstatic_cast(DcmElement *, stack.top()); - if (element != NULL) -diff --git a/dcmsign/libsrc/dcsignat.cc b/dcmsign/libsrc/dcsignat.cc -index b104ec1e81..c5b57099a4 100644 ---- a/dcmsign/libsrc/dcsignat.cc -+++ b/dcmsign/libsrc/dcsignat.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2000-2023, OFFIS e.V. -+ * Copyright (C) 2000-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -104,7 +104,7 @@ OFCondition DcmSignature::getMACIDnumber(DcmItem &item, Uint16& macid) - macid = 0xFFFF; - DcmStack stack; - OFCondition result = item.search(DCM_MACIDNumber, stack, ESM_fromHere, OFFalse); -- if (result.good() && (stack.top()->isLeaf())) -+ if (result.good() && (stack.top()->isElement())) - { - result = ((DcmElement *)(stack.top()))->getUint16(macid); - } -@@ -734,7 +734,7 @@ OFCondition DcmSignature::verifyCurrent() - // read MAC Calculation Transfer Syntax UID - if (result.good()) - { -- if ((selectedMacParametersItem->search(DCM_MACCalculationTransferSyntaxUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedMacParametersItem->search(DCM_MACCalculationTransferSyntaxUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - char *uid = NULL; - if ((((DcmElement *)(stack.top()))->getString(uid)).good()) -@@ -750,7 +750,7 @@ OFCondition DcmSignature::verifyCurrent() - if (result.good()) - { - stack.clear(); -- if ((selectedMacParametersItem->search(DCM_MACAlgorithm, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedMacParametersItem->search(DCM_MACAlgorithm, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - OFString macidentifier; - if ((((DcmElement *)(stack.top()))->getOFString(macidentifier, 0)).good()) -@@ -783,7 +783,7 @@ OFCondition DcmSignature::verifyCurrent() - if (result.good()) - { - stack.clear(); -- if ((selectedSignatureItem->search(DCM_Signature, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedSignatureItem->search(DCM_Signature, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->ident() == EVR_OB)) - { - signature = new DcmOtherByteOtherWord(*((DcmOtherByteOtherWord *)(stack.top()))); - if (signature == NULL) result = EC_MemoryExhausted; -@@ -960,7 +960,7 @@ OFCondition DcmSignature::getCurrentMacXferSyntaxName(OFString& str) - DcmStack stack; - - // read MAC Calculation Transfer Syntax UID -- if ((selectedMacParametersItem->search(DCM_MACCalculationTransferSyntaxUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedMacParametersItem->search(DCM_MACCalculationTransferSyntaxUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - char *uid = NULL; - if ((((DcmElement *)(stack.top()))->getString(uid)).good() && uid) -@@ -1005,7 +1005,7 @@ OFCondition DcmSignature::getCurrentMacName(OFString& str) - DcmStack stack; - - // read MAC Algorithm -- if ((selectedMacParametersItem->search(DCM_MACAlgorithm, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedMacParametersItem->search(DCM_MACAlgorithm, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - if ((((DcmElement *)(stack.top()))->getOFString(str, 0)).good()) result = EC_Normal; - } -@@ -1020,7 +1020,7 @@ OFCondition DcmSignature::getCurrentSignatureUID(OFString& str) - DcmStack stack; - - // read signature UID -- if ((selectedSignatureItem->search(DCM_DigitalSignatureUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedSignatureItem->search(DCM_DigitalSignatureUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - if ((((DcmElement *)(stack.top()))->getOFString(str, 0)).good()) result = EC_Normal; - } -@@ -1048,7 +1048,7 @@ OFCondition DcmSignature::getCurrentSignatureDateTime(OFString& str) - DcmStack stack; - - // read signature date/time -- if ((selectedSignatureItem->search(DCM_DigitalSignatureDateTime, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedSignatureItem->search(DCM_DigitalSignatureDateTime, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - if ((((DcmElement *)(stack.top()))->getOFString(str, 0)).good()) result = EC_Normal; - } -@@ -1119,7 +1119,7 @@ OFCondition DcmSignature::verifySignatureProfile(SiSecurityProfile &sprof) - // check MAC Calculation Transfer Syntax UID - if (result.good()) - { -- if ((selectedMacParametersItem->search(DCM_MACCalculationTransferSyntaxUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedMacParametersItem->search(DCM_MACCalculationTransferSyntaxUID, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - char *uid = NULL; - if ((((DcmElement *)(stack.top()))->getString(uid)).good()) -@@ -1142,7 +1142,7 @@ OFCondition DcmSignature::verifySignatureProfile(SiSecurityProfile &sprof) - { - E_MACType mac = EMT_RIPEMD160; - stack.clear(); -- if ((selectedMacParametersItem->search(DCM_MACAlgorithm, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isLeaf())) -+ if ((selectedMacParametersItem->search(DCM_MACAlgorithm, stack, ESM_fromHere, OFFalse)).good() && (stack.top()->isElement())) - { - OFString macidentifier; - if ((((DcmElement *)(stack.top()))->getOFString(macidentifier, 0)).good()) -diff --git a/dcmsign/libsrc/sicert.cc b/dcmsign/libsrc/sicert.cc -index 173bbbf2c3..0668b72c99 100644 ---- a/dcmsign/libsrc/sicert.cc -+++ b/dcmsign/libsrc/sicert.cc -@@ -135,7 +135,7 @@ OFCondition SiCertificate::read(DcmItem& item) - OFString aString; - DcmStack stack; - result = item.search(DCM_CertificateType, stack, ESM_fromHere, OFFalse); -- if (result.good()) -+ if (result.good() && stack.top()->isElement()) - { - result = ((DcmElement *)(stack.top()))->getOFString(aString, 0); - if (result.good()) -@@ -144,7 +144,7 @@ OFCondition SiCertificate::read(DcmItem& item) - { - stack.clear(); - result = item.search(DCM_CertificateOfSigner, stack, ESM_fromHere, OFFalse); -- if (result.good()) -+ if (result.good() && stack.top()->isElement()) - { - DcmElement *cert = (DcmElement *)stack.top(); - Uint8 *data = NULL; -diff --git a/dcmsr/libsrc/dsrtypes.cc b/dcmsr/libsrc/dsrtypes.cc -index 08414ad93e..a9d6218594 100644 ---- a/dcmsr/libsrc/dsrtypes.cc -+++ b/dcmsr/libsrc/dsrtypes.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2000-2023, OFFIS e.V. -+ * Copyright (C) 2000-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -1178,7 +1178,7 @@ OFCondition DSRTypes::getAndCheckElementFromDataset(DcmItem &dataset, - DcmStack stack; - const DcmTagKey tagKey = delem.getTag(); - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good()) -+ if (result.good() && stack.top()->isElement()) - { - /* copy object from search stack */ - result = delem.copyFrom(*stack.top()); -@@ -1203,7 +1203,7 @@ OFCondition DSRTypes::getAndCheckStringValueFromDataset(DcmItem &dataset, - { - DcmStack stack; - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good()) -+ if (result.good() && stack.top()->isElement()) - { - DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); - /* we need a reference to the original element in order to determine the SpecificCharacterSet */ diff --git a/debian/patches/0002-Fixed-unchecked-typecasts-and-fixed-LUT-handling.patch b/debian/patches/0002-Fixed-unchecked-typecasts-and-fixed-LUT-handling.patch deleted file mode 100644 index 3091283c..00000000 --- a/debian/patches/0002-Fixed-unchecked-typecasts-and-fixed-LUT-handling.patch +++ /dev/null @@ -1,503 +0,0 @@ -From 601b227eecaab33a3a3a11dc256d84b1a62f63af Mon Sep 17 00:00:00 2001 -From: Marco Eichelberg -Date: Mon, 15 Apr 2024 12:19:33 +0200 -Subject: [PATCH] Fixed unchecked typecasts and fixed LUT handling. - -This commit adds further fixes for unchecked typecasts of DcmItem::search() -results (see description of previous commit). Furthermore, this commit -specifically addresses the handling of look-up tables (LUTs) in module -dcmpstat, where attribute (0028,3006) LUTData may use either US or OW -value representation, and (0028,3002) LUTDescriptor may be either US or SS. -The code should now properly handle all permitted value representations. -LUTData is now always written as OW in order to avoid the 64k size limit -for US in explicit VR encoding. - -Thanks to Martin Zeiser from the Cisco Talos team - for the bug report (TALOS-2024-1957). - -Together with the previous commit, this closes DCMTK issue #1120. ---- - dcmpstat/libsrc/dcmpstat.cc | 40 ++++++++++++++++------- - dcmpstat/libsrc/dvpspl.cc | 34 +++++++++++++------ - dcmpstat/libsrc/dvpssv.cc | 34 +++++++++++++------ - dcmpstat/libsrc/dvpssvl.cc | 25 +++++++++----- - dcmpstat/libsrc/dvpstat.cc | 65 +++++++++++++++++-------------------- - dcmpstat/libsrc/dvpsvl.cc | 19 +++++++++-- - 6 files changed, 139 insertions(+), 78 deletions(-) - -diff --git a/dcmpstat/libsrc/dcmpstat.cc b/dcmpstat/libsrc/dcmpstat.cc -index 4a8e5af6c3..a7d11abaca 100644 ---- a/dcmpstat/libsrc/dcmpstat.cc -+++ b/dcmpstat/libsrc/dcmpstat.cc -@@ -384,12 +384,16 @@ OFCondition DcmPresentationState::read(DcmItem &dset) - { - item = seq->getItem(0); - stack.clear(); -- // LUTDescriptor can be US or SS. For now we only handle US. -+ -+ // LUTDescriptor can be US or SS - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTDescriptor.getTag(), -- stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_SS)) - { -- modalityLUTDescriptor = *((DcmUnsignedShort *)(stack.top())); -+ // We explicitly use DcmElement::operator=(), which works for US and SS -+ DcmElement *mLUTDescriptor = &modalityLUTDescriptor; -+ mLUTDescriptor->operator=(* OFstatic_cast(DcmElement *, stack.top())); - } -+ - stack.clear(); - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTExplanation.getTag(), - stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_LO)) -@@ -400,9 +404,11 @@ OFCondition DcmPresentationState::read(DcmItem &dset) - - // LUTData can be OW, US or SS. For now we only handle US. - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTData.getTag(), -- stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_OW)) - { -- modalityLUTData = *((DcmUnsignedShort *)(stack.top())); -+ // we deliberately call DcmElement::operator=() here, which will work for both DcmUnsignedShort and DcmOtherByteOtherWord parameters -+ DcmElement *mdata = &modalityLUTData; -+ mdata->operator=(*(DcmElement *)(stack.top())); - } - stack.clear(); - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTType.getTag(), -@@ -879,11 +885,13 @@ OFCondition DcmPresentationState::createFromImage( - { - item = seq->getItem(0); - stack.clear(); -- // LUTDescriptor can be US or SS. For now we only handle US. -+ // LUTDescriptor can be US or SS - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTDescriptor.getTag(), -- stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_SS)) - { -- modalityLUTDescriptor = *((DcmUnsignedShort *)(stack.top())); -+ // We explicitly use DcmElement::operator=(), which works for US and SS -+ DcmElement *mLUTDescriptor = &modalityLUTDescriptor; -+ mLUTDescriptor->operator=(* OFstatic_cast(DcmElement *, stack.top())); - } - stack.clear(); - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTExplanation.getTag(), -@@ -895,9 +903,11 @@ OFCondition DcmPresentationState::createFromImage( - - // LUTData can be OW, US or SS. For now we only handle US. - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTData.getTag(), -- stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US)) -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_OW)) - { -- modalityLUTData = *((DcmUnsignedShort *)(stack.top())); -+ // we deliberately call DcmElement::operator=() here, which will work for both DcmUnsignedShort and DcmOtherByteOtherWord parameters -+ DcmElement *mdata = &modalityLUTData; -+ mdata->operator=(*(DcmElement *)(stack.top())); - } - stack.clear(); - if ((EC_Normal == item->search((DcmTagKey &)modalityLUTType.getTag(), -@@ -1247,10 +1257,16 @@ OFCondition DcmPresentationState::write(DcmItem &dset, OFBool replaceSOPInstance - dseq = new DcmSequenceOfItems(DCM_ModalityLUTSequence); - if (dseq) - { -- delem = new DcmUnsignedShort(modalityLUTDescriptor); -+ // we clone modalityLUTDescriptor in order to retain the VR (US or SS) -+ delem = OFstatic_cast(DcmElement *, modalityLUTDescriptor.clone()); - if (delem) ditem->insert(delem, OFTrue /*replaceOld*/); else result=EC_MemoryExhausted; -- delem = new DcmUnsignedShort(modalityLUTData); -+ -+ // we write LUTData as OW in order to avoid the 64 kByte limit for US -+ delem = new DcmOtherByteOtherWord(DCM_LUTData); -+ delem->operator=(modalityLUTData); -+ OFstatic_cast(DcmOtherByteOtherWord *, delem)->setVR(EVR_OW); - if (delem) ditem->insert(delem, OFTrue /*replaceOld*/); else result=EC_MemoryExhausted; -+ - delem = new DcmLongString(modalityLUTType); - if (delem) ditem->insert(delem, OFTrue /*replaceOld*/); else result=EC_MemoryExhausted; - if (modalityLUTExplanation.getLength() >0) -diff --git a/dcmpstat/libsrc/dvpspl.cc b/dcmpstat/libsrc/dvpspl.cc -index ec4cccf973..f5574ab337 100644 ---- a/dcmpstat/libsrc/dvpspl.cc -+++ b/dcmpstat/libsrc/dvpspl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1999-2018, OFFIS e.V. -+ * Copyright (C) 1999-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -24,6 +24,7 @@ - #include "dcmtk/dcmdata/dcdeftag.h" - #include "dcmtk/dcmdata/dcsequen.h" - #include "dcmtk/dcmdata/dcvrcs.h" -+#include "dcmtk/dcmdata/dcvrobow.h" - #include "dcmtk/dcmpstat/dvpspl.h" - #include "dcmtk/dcmpstat/dvpsdef.h" /* for constants and macros */ - #include "dcmtk/dcmnet/dimse.h" -@@ -79,29 +80,36 @@ OFCondition DVPSPresentationLUT::read(DcmItem &dset, OFBool withSOPInstance) - if (result==EC_Normal) - { - stack.clear(); -- if (EC_Normal == dset.search(DCM_PresentationLUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_PresentationLUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) - { - item = seq->getItem(0); - stack.clear(); -- if (EC_Normal == item->search((DcmTagKey &)presentationLUTDescriptor.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ -+ // LUTDescriptor can be US or SS -+ if ((EC_Normal == item->search((DcmTagKey &)presentationLUTDescriptor.getTag(), -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_SS)) - { -- presentationLUTDescriptor = *((DcmUnsignedShort *)(stack.top())); -+ // We explicitly use DcmElement::operator=(), which works for US and SS -+ DcmElement *pLUTDescriptor = &presentationLUTDescriptor; -+ pLUTDescriptor->operator=(* OFstatic_cast(DcmElement *, stack.top())); - } -+ - stack.clear(); - if (EC_Normal == item->search((DcmTagKey &)presentationLUTExplanation.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_LO)) - { - presentationLUTExplanation = *((DcmLongString *)(stack.top())); - } - stack.clear(); - if (EC_Normal == item->search((DcmTagKey &)presentationLUTData.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_OW)) - { -- presentationLUTData = *((DcmUnsignedShort *)(stack.top())); -+ // we deliberately call DcmElement::operator=() here, which will work for both DcmUnsignedShort and DcmOtherByteOtherWord parameters -+ DcmElement *pldata = &presentationLUTData; -+ pldata->operator=(*(DcmElement *)(stack.top())); - } - } else { - result=EC_TagNotFound; -@@ -187,10 +195,16 @@ OFCondition DVPSPresentationLUT::write(DcmItem &dset, OFBool withSOPInstance) - dseq = new DcmSequenceOfItems(DCM_PresentationLUTSequence); - if (dseq) - { -- delem = new DcmUnsignedShort(presentationLUTDescriptor); -+ // we clone presentationLUTDescriptor in order to retain the VR (US or SS) -+ delem = OFstatic_cast(DcmElement *, presentationLUTDescriptor.clone()); - if (delem) ditem->insert(delem, OFTrue /*replaceOld*/); else result=EC_MemoryExhausted; -- delem = new DcmUnsignedShort(presentationLUTData); -+ -+ // we write LUTData as OW in order to avoid the 64 kByte limit for US -+ delem = new DcmOtherByteOtherWord(DCM_LUTData); -+ delem->operator=(presentationLUTData); -+ OFstatic_cast(DcmOtherByteOtherWord *, delem)->setVR(EVR_OW); - if (delem) ditem->insert(delem, OFTrue /*replaceOld*/); else result=EC_MemoryExhausted; -+ - if (presentationLUTExplanation.getLength() >0) - { - delem = new DcmLongString(presentationLUTExplanation); -diff --git a/dcmpstat/libsrc/dvpssv.cc b/dcmpstat/libsrc/dvpssv.cc -index 8e3d49bd4f..4a7fd0e309 100644 ---- a/dcmpstat/libsrc/dvpssv.cc -+++ b/dcmpstat/libsrc/dvpssv.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2018, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -23,6 +23,7 @@ - #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ - #include "dcmtk/dcmdata/dcdeftag.h" - #include "dcmtk/dcmdata/dcsequen.h" -+#include "dcmtk/dcmdata/dcvrobow.h" - #include "dcmtk/dcmpstat/dvpssv.h" - #include "dcmtk/dcmpstat/dvpsri.h" /* for DVPSReferencedImage */ - #include "dcmtk/dcmpstat/dvpsrsl.h" /* DVPSReferencedSeries_PList */ -@@ -75,29 +76,36 @@ OFCondition DVPSSoftcopyVOI::read(DcmItem &dset) - if (result==EC_Normal) - { - stack.clear(); -- if (EC_Normal == dset.search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() ==1) - { - item = seq->getItem(0); - stack.clear(); -- if (EC_Normal == item->search((DcmTagKey &)voiLUTDescriptor.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ -+ // LUTDescriptor can be US or SS -+ if ((EC_Normal == item->search((DcmTagKey &)voiLUTDescriptor.getTag(), -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_SS)) - { -- voiLUTDescriptor = *((DcmUnsignedShort *)(stack.top())); -+ // We explicitly use DcmElement::operator=(), which works for US and SS -+ DcmElement *vLUTDescriptor = &voiLUTDescriptor; -+ vLUTDescriptor->operator=(* OFstatic_cast(DcmElement *, stack.top())); - } -+ - stack.clear(); - if (EC_Normal == item->search((DcmTagKey &)voiLUTExplanation.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_LO)) - { - voiLUTExplanation = *((DcmLongString *)(stack.top())); - } - stack.clear(); - if (EC_Normal == item->search((DcmTagKey &)voiLUTData.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_OW)) - { -- voiLUTData = *((DcmUnsignedShort *)(stack.top())); -+ // we deliberately call DcmElement::operator=() here, which will work for both DcmUnsignedShort and DcmOtherByteOtherWord parameters -+ DcmElement *vldata = &voiLUTData; -+ vldata->operator=(*(DcmElement *)(stack.top())); - } - } else { - result=EC_TagNotFound; -@@ -177,10 +185,16 @@ OFCondition DVPSSoftcopyVOI::write(DcmItem &dset) - dseq = new DcmSequenceOfItems(DCM_VOILUTSequence); - if (dseq) - { -- delem = new DcmUnsignedShort(voiLUTDescriptor); -+ // we clone voiLUTDescriptor in order to retain the VR (US or SS) -+ delem = OFstatic_cast(DcmElement *, voiLUTDescriptor.clone()); - if (delem) ditem->insert(delem, OFTrue /*replaceOld*/); else result=EC_MemoryExhausted; -- delem = new DcmUnsignedShort(voiLUTData); -+ -+ // we write LUTData as OW in order to avoid the 64 kByte limit for US -+ delem = new DcmOtherByteOtherWord(DCM_LUTData); -+ delem->operator=(voiLUTData); -+ OFstatic_cast(DcmOtherByteOtherWord *, delem)->setVR(EVR_OW); - if (delem) ditem->insert(delem, OFTrue /*replaceOld*/); else result=EC_MemoryExhausted; -+ - if (voiLUTExplanation.getLength() >0) - { - delem = new DcmLongString(voiLUTExplanation); -diff --git a/dcmpstat/libsrc/dvpssvl.cc b/dcmpstat/libsrc/dvpssvl.cc -index d1532db5c2..efcb6a26be 100644 ---- a/dcmpstat/libsrc/dvpssvl.cc -+++ b/dcmpstat/libsrc/dvpssvl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1999-2023, OFFIS e.V. -+ * Copyright (C) 1999-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -72,7 +72,7 @@ OFCondition DVPSSoftcopyVOI_PList::read(DcmItem &dset) - DcmSequenceOfItems *dseq=NULL; - DcmItem *ditem=NULL; - -- if (EC_Normal == dset.search(DCM_SoftcopyVOILUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_SoftcopyVOILUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - dseq=(DcmSequenceOfItems *)stack.top(); - if (dseq) -@@ -249,29 +249,36 @@ OFCondition DVPSSoftcopyVOI_PList::createFromImage( - if (result==EC_Normal) - { - stack.clear(); -- if (EC_Normal == dset.search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dset.search(DCM_VOILUTSequence, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_SQ)) - { - seq=(DcmSequenceOfItems *)stack.top(); - if (seq->card() > 0) - { - item = seq->getItem(0); - stack.clear(); -- if (EC_Normal == item->search((DcmTagKey &)voiLUTDescriptor.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ -+ // LUTDescriptor can be US or SS -+ if ((EC_Normal == item->search((DcmTagKey &)voiLUTDescriptor.getTag(), -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_SS)) - { -- voiLUTDescriptor = *((DcmUnsignedShort *)(stack.top())); -+ // We explicitly use DcmElement::operator=(), which works for US and SS -+ DcmElement *vLUTDescriptor = &voiLUTDescriptor; -+ vLUTDescriptor->operator=(* OFstatic_cast(DcmElement *, stack.top())); - } -+ - stack.clear(); - if (EC_Normal == item->search((DcmTagKey &)voiLUTExplanation.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_LO)) - { - voiLUTExplanation = *((DcmLongString *)(stack.top())); - } - stack.clear(); - if (EC_Normal == item->search((DcmTagKey &)voiLUTData.getTag(), -- stack, ESM_fromHere, OFFalse)) -+ stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_OW)) - { -- voiLUTData = *((DcmUnsignedShort *)(stack.top())); -+ // we deliberately call DcmElement::operator=() here, which will work for both DcmUnsignedShort and DcmOtherByteOtherWord parameters -+ DcmElement *vldata = &voiLUTData; -+ vldata->operator=(*(DcmElement *)(stack.top())); - } - } else result=EC_TagNotFound; - } -diff --git a/dcmpstat/libsrc/dvpstat.cc b/dcmpstat/libsrc/dvpstat.cc -index ce2f5ad5ff..4bfe8f9cbd 100644 ---- a/dcmpstat/libsrc/dvpstat.cc -+++ b/dcmpstat/libsrc/dvpstat.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1998-2021, OFFIS e.V. -+ * Copyright (C) 1998-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -578,14 +578,14 @@ OFCondition DVPresentationState::attachImage(DcmDataset *dataset, OFBool transfe - currentImageSelectedFrame = 1; // default: first frame - - // get Modality -- if (EC_Normal == dataset->search(DCM_Modality, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dataset->search(DCM_Modality, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_CS)) - { - currentImageModality = *((DcmCodeString *)(stack.top())); - } - stack.clear(); - - // determine default Presentation LUT Shape -- if (EC_Normal == dataset->search(DCM_PhotometricInterpretation, stack, ESM_fromHere, OFFalse)) -+ if (EC_Normal == dataset->search(DCM_PhotometricInterpretation, stack, ESM_fromHere, OFFalse) && (stack.top()->ident() == EVR_CS)) - { - DcmCodeString *photometricInterpretation = (DcmCodeString *)(stack.top()); - if (photometricInterpretation->getVM() == 1) -@@ -598,12 +598,12 @@ OFCondition DVPresentationState::attachImage(DcmDataset *dataset, OFBool transfe - stack.clear(); - - // get SOP class UID and SOP instance UID. -- if ((EC_Normal == result)&&(EC_Normal == dataset->search(DCM_SOPClassUID, stack, ESM_fromHere, OFFalse))) -+ if ((EC_Normal == result)&&(EC_Normal == dataset->search(DCM_SOPClassUID, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_UI)) - { - result = ((DcmUniqueIdentifier *)(stack.top()))->getString(currentImageSOPClassUID); - } - stack.clear(); -- if ((EC_Normal == result)&&(EC_Normal == dataset->search(DCM_SOPInstanceUID, stack, ESM_fromHere, OFFalse))) -+ if ((EC_Normal == result)&&(EC_Normal == dataset->search(DCM_SOPInstanceUID, stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_UI)) - { - result = ((DcmUniqueIdentifier *)(stack.top()))->getString(currentImageSOPInstanceUID); - } -@@ -1124,40 +1124,36 @@ OFCondition DVPresentationState::setGammaVOILUT(double gammaValue, DVPSObjectApp - numEntries16 = (Uint16)numberOfEntries; - - /* LUT Descriptor */ -- DcmElement *lutDescriptor = NULL; -- if (firstMapped < 0) -+ DcmUnsignedShort *lutDescriptor = new DcmUnsignedShort(DcmTag(DCM_LUTDescriptor, EVR_US)); -+ if (lutDescriptor == NULL) status = EC_MemoryExhausted; -+ else - { -- // LUT Descriptor is SS -- lutDescriptor = new DcmSignedShort(DcmTag(DCM_LUTDescriptor, EVR_SS)); -- if (lutDescriptor != NULL) -+ if (firstMapped < 0) - { -- status = lutDescriptor->putSint16((Sint16)numEntries16, 0); -- if (EC_Normal == status) -- status = lutDescriptor->putSint16((Sint16)firstMapped, 1); -- if (EC_Normal == status) -- status = lutDescriptor->putSint16((Sint16)numberOfBits, 2); -- } else -- status = EC_MemoryExhausted; -- } else { -- // LUT Descriptor is US -- lutDescriptor = new DcmUnsignedShort(DcmTag(DCM_LUTDescriptor, EVR_US)); -- if (lutDescriptor != NULL) -- { -- status = lutDescriptor->putUint16(numEntries16, 0); -- if (EC_Normal == status) -- status = lutDescriptor->putUint16((Uint16)firstMapped, 1); -- if (EC_Normal == status) -- status = lutDescriptor->putUint16((Uint16)numberOfBits, 2); -- } else -- status = EC_MemoryExhausted; -+ // LUT Descriptor is SS -+ DcmSignedShort ldesc(DcmTag(DCM_LUTDescriptor, EVR_SS)); -+ status = ldesc.putSint16((Sint16)numEntries16, 0); -+ if (EC_Normal == status) status = ldesc.putSint16((Sint16)firstMapped, 1); -+ if (EC_Normal == status) status = ldesc.putSint16((Sint16)numberOfBits, 2); -+ if (EC_Normal == status) -+ { -+ // copy content of SS element into DcmUnsignedShort using DcmElement::operator= -+ DcmElement *ld = lutDescriptor; -+ ld->operator=(ldesc); -+ } -+ } else { -+ // LUT Descriptor is US -+ status = lutDescriptor->putUint16(numEntries16, 0); -+ if (EC_Normal == status) status = lutDescriptor->putUint16((Uint16)firstMapped, 1); -+ if (EC_Normal == status) status = lutDescriptor->putUint16((Uint16)numberOfBits, 2); -+ } - } - - /* LUT Data */ -- DcmElement *lutData = NULL; -+ DcmUnsignedShort *lutData = NULL; - if (status == EC_Normal) - { -- // LUT Data as OW, because of max size = 64K -- lutData = new DcmOtherByteOtherWord(DcmTag(DCM_LUTData, EVR_OW)); -+ lutData = new DcmUnsignedShort(DcmTag(DCM_LUTData, EVR_US)); - if (lutData != NULL) - status = lutData->putUint16Array(data, numberOfEntries); - else -@@ -1186,15 +1182,14 @@ OFCondition DVPresentationState::setGammaVOILUT(double gammaValue, DVPSObjectApp - if (status == EC_Normal) - { - if ((lutDescriptor != NULL) && (lutData != NULL) && (lutExplanation != NULL)) -- status = setVOILUT(*(DcmUnsignedShort *)lutDescriptor, *(DcmUnsignedShort *)lutData, *lutExplanation, applicability); -+ status = setVOILUT(*lutDescriptor, *lutData, *lutExplanation, applicability); - } - - /* delete temporary dcmtk structures */ - delete lutDescriptor; - delete lutData; - delete lutExplanation; -- } else -- status = EC_MemoryExhausted; -+ } else status = EC_MemoryExhausted; - delete[] data; - } - return status; -diff --git a/dcmpstat/libsrc/dvpsvl.cc b/dcmpstat/libsrc/dvpsvl.cc -index b10b83f20d..fdba0a0e06 100644 ---- a/dcmpstat/libsrc/dvpsvl.cc -+++ b/dcmpstat/libsrc/dvpsvl.cc -@@ -59,9 +59,24 @@ OFCondition DVPSVOILUT::read(DcmItem &dset) - OFCondition result = EC_Normal; - DcmStack stack; - -- READ_FROM_DATASET(DcmUnsignedShort, EVR_US, voiLUTDescriptor) -+ // LUTDescriptor can be US or SS -+ if ((EC_Normal == dset.search((DcmTagKey &)voiLUTDescriptor.getTag(), -+ stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_SS)) -+ { -+ // We explicitly use DcmElement::operator=(), which works for US and SS -+ DcmElement *vLUTDescriptor = &voiLUTDescriptor; -+ vLUTDescriptor->operator=(* OFstatic_cast(DcmElement *, stack.top())); -+ } -+ - READ_FROM_DATASET(DcmLongString, EVR_LO, voiLUTExplanation) -- READ_FROM_DATASET(DcmUnsignedShort, EVR_US, voiLUTData) -+ -+ stack.clear(); -+ if ((EC_Normal == dset.search((DcmTagKey &)voiLUTData.getTag(), stack, ESM_fromHere, OFFalse)) && (stack.top()->ident() == EVR_US || stack.top()->ident() == EVR_OW)) -+ { -+ // we deliberately call DcmElement::operator=() here, which will work for both DcmUnsignedShort and DcmOtherByteOtherWord parameters -+ DcmElement *vldata = &voiLUTData; -+ vldata->operator=(*(DcmElement *)(stack.top())); -+ } - - if (EC_Normal == result) - { diff --git a/debian/patches/0003-Fixed-wrong-error-handling-previous-commit.patch b/debian/patches/0003-Fixed-wrong-error-handling-previous-commit.patch deleted file mode 100644 index db629e0a..00000000 --- a/debian/patches/0003-Fixed-wrong-error-handling-previous-commit.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 7d54f8efec995e5601d089fa17b0625c2b41af23 Mon Sep 17 00:00:00 2001 -From: Joerg Riesmeier -Date: Mon, 22 Apr 2024 12:11:11 +0200 -Subject: [PATCH] Fixed wrong error handling (previous commit). - -Fixed wrong error handling introduced with the previous commit. ---- - dcmrt/libsrc/drttypes.cc | 6 +++--- - dcmsr/libsrc/dsrtypes.cc | 32 ++++++++++++++++++++------------ - 2 files changed, 23 insertions(+), 15 deletions(-) - -diff --git a/dcmrt/libsrc/drttypes.cc b/dcmrt/libsrc/drttypes.cc -index 77ff1674c..097ab9727 100644 ---- a/dcmrt/libsrc/drttypes.cc -+++ b/dcmrt/libsrc/drttypes.cc -@@ -210,11 +210,11 @@ OFCondition DRTTypes::getAndCheckStringValueFromDataset(DcmItem &dataset, - { - DcmStack stack; - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good() && stack.top()->isElement()) -+ if (result.good()) - { -- DcmElement *element = OFstatic_cast(DcmElement *, stack.top()); -- if (element != NULL) -+ if (stack.top()->isElement()) - { -+ DcmElement *element = OFstatic_cast(DcmElement *, stack.top()); - if (checkElementValue(*element, vm, type, result, moduleName)) - result = element->getOFString(stringValue, 0); - else -diff --git a/dcmsr/libsrc/dsrtypes.cc b/dcmsr/libsrc/dsrtypes.cc -index a9d621859..166bfabff 100644 ---- a/dcmsr/libsrc/dsrtypes.cc -+++ b/dcmsr/libsrc/dsrtypes.cc -@@ -1178,13 +1178,17 @@ OFCondition DSRTypes::getAndCheckElementFromDataset(DcmItem &dataset, - DcmStack stack; - const DcmTagKey tagKey = delem.getTag(); - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good() && stack.top()->isElement()) -+ if (result.good()) - { -- /* copy object from search stack */ -- result = delem.copyFrom(*stack.top()); -- /* we need a reference to the original element in order to determine the SpecificCharacterSet */ -- if (!checkElementValue(OFstatic_cast(DcmElement *, stack.top()), tagKey, vm, type, result, moduleName, acceptViolation)) -- result = SR_EC_InvalidValue; -+ if (stack.top()->isElement()) -+ { -+ /* copy object from search stack */ -+ result = delem.copyFrom(*stack.top()); -+ /* we need a reference to the original element in order to determine the SpecificCharacterSet */ -+ if (!checkElementValue(OFstatic_cast(DcmElement *, stack.top()), tagKey, vm, type, result, moduleName, acceptViolation)) -+ result = SR_EC_InvalidValue; -+ } else -+ result = EC_CorruptedData; - } - /* the element could not be found in the dataset */ - else if (!checkElementValue(delem, vm, type, result, moduleName, acceptViolation)) -@@ -1203,13 +1207,17 @@ OFCondition DSRTypes::getAndCheckStringValueFromDataset(DcmItem &dataset, - { - DcmStack stack; - OFCondition result = dataset.search(tagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/); -- if (result.good() && stack.top()->isElement()) -+ if (result.good()) - { -- DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); -- /* we need a reference to the original element in order to determine the SpecificCharacterSet */ -- if (!checkElementValue(delem, tagKey, vm, type, result, moduleName, acceptViolation)) -- result = SR_EC_InvalidValue; -- delem->getOFString(stringValue, 0); -+ if (stack.top()->isElement()) -+ { -+ DcmElement *delem = OFstatic_cast(DcmElement *, stack.top()); -+ /* we need a reference to the original element in order to determine the SpecificCharacterSet */ -+ if (!checkElementValue(delem, tagKey, vm, type, result, moduleName, acceptViolation)) -+ result = SR_EC_InvalidValue; -+ delem->getOFString(stringValue, 0); -+ } else -+ result = EC_CorruptedData; - } else { - if ((type == "1") || (type == "2")) - { diff --git a/debian/patches/0004-Fixed-two-segmentation-faults.patch b/debian/patches/0004-Fixed-two-segmentation-faults.patch deleted file mode 100644 index f8658734..00000000 --- a/debian/patches/0004-Fixed-two-segmentation-faults.patch +++ /dev/null @@ -1,95 +0,0 @@ -From c78e434c0c5f9d932874f0b17a8b4ce305ca01f5 Mon Sep 17 00:00:00 2001 -From: Marco Eichelberg -Date: Wed, 13 Mar 2024 17:15:58 +0100 -Subject: [PATCH] Fixed two segmentation faults. - -Fixed two segmentations faults that could occur while processing an -invalid incoming DIMSE message due to insufficient error handling -causing a de-referenced NULL pointer. - -Thanks to Nils Bars for the bug report and sample files. - -This closes DCMTK issue #1114. ---- - dcmdata/libsrc/dcelem.cc | 9 ++++++++- - dcmnet/libsrc/dimcmd.cc | 33 ++++++++++++++++++--------------- - 2 files changed, 26 insertions(+), 16 deletions(-) - -diff --git a/dcmdata/libsrc/dcelem.cc b/dcmdata/libsrc/dcelem.cc -index 1524904be..3b9cc2bf7 100644 ---- a/dcmdata/libsrc/dcelem.cc -+++ b/dcmdata/libsrc/dcelem.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2023, OFFIS e.V. -+ * Copyright (C) 1994-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -717,6 +717,13 @@ OFCondition DcmElement::loadValue(DcmInputStream *inStream) - if (isStreamNew) - delete readStream; - } -+ else -+ { -+ errorFlag = EC_InvalidStream; // incomplete dataset read from stream -+ DCMDATA_ERROR("DcmElement: " << getTagName() << " " << getTag() -+ << " larger (" << getLengthField() << ") than remaining bytes (" -+ << getTransferredBytes() << ") in file, premature end of stream"); -+ } - } - /* return result value */ - return errorFlag; -diff --git a/dcmnet/libsrc/dimcmd.cc b/dcmnet/libsrc/dimcmd.cc -index 6dca39546..ffd225f4b 100644 ---- a/dcmnet/libsrc/dimcmd.cc -+++ b/dcmnet/libsrc/dimcmd.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2022, OFFIS e.V. -+ * Copyright (C) 1994-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were partly developed by -@@ -205,22 +205,25 @@ getString(DcmDataset *obj, DcmTagKey t, char *s, int maxlen, OFBool *spacePadded - return parseErrorWithMsg("dimcmd:getString: string too small", t); - } else { - ec = elem->getString(aString); -- strncpy(s, aString, maxlen); -- if (spacePadded) -+ if (ec.good()) - { -- /* before we remove leading and tailing spaces we want to know -- * whether the string is actually space padded. Required to communicate -- * with dumb peers which send space padded UIDs and fail if they -- * receive correct UIDs back. -- * -- * This test can only detect space padded strings if -- * dcmEnableAutomaticInputDataCorrection is false; otherwise the padding -- * has already been removed by dcmdata at this stage. -- */ -- size_t s_len = strlen(s); -- if ((s_len > 0)&&(s[s_len-1] == ' ')) *spacePadded = OFTrue; else *spacePadded = OFFalse; -+ strncpy(s, aString, maxlen); -+ if (spacePadded) -+ { -+ /* before we remove leading and tailing spaces we want to know -+ * whether the string is actually space padded. Required to communicate -+ * with dumb peers which send space padded UIDs and fail if they -+ * receive correct UIDs back. -+ * -+ * This test can only detect space padded strings if -+ * dcmEnableAutomaticInputDataCorrection is false; otherwise the padding -+ * has already been removed by dcmdata at this stage. -+ */ -+ size_t s_len = strlen(s); -+ if ((s_len > 0)&&(s[s_len-1] == ' ')) *spacePadded = OFTrue; else *spacePadded = OFFalse; -+ } -+ DU_stripLeadingAndTrailingSpaces(s); - } -- DU_stripLeadingAndTrailingSpaces(s); - } - } - return (ec.good())? ec : DIMSE_PARSEFAILED; diff --git a/debian/patches/0005-Fixed-DcmDecimalString-unit-tests.patch b/debian/patches/0005-Fixed-DcmDecimalString-unit-tests.patch deleted file mode 100644 index ee1dcfc1..00000000 --- a/debian/patches/0005-Fixed-DcmDecimalString-unit-tests.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 66c317feae446deda1a389226aa24c95a0eeac4c Mon Sep 17 00:00:00 2001 -From: Marco Eichelberg -Date: Wed, 13 Mar 2024 23:03:40 +0100 -Subject: [PATCH] Fixed DcmDecimalString unit tests. - ---- - dcmdata/tests/tvrds.cc | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/dcmdata/tests/tvrds.cc b/dcmdata/tests/tvrds.cc -index a9132a341..0e929304d 100644 ---- a/dcmdata/tests/tvrds.cc -+++ b/dcmdata/tests/tvrds.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2011-2020, OFFIS e.V. -+ * Copyright (C) 2011-2024, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -30,7 +30,7 @@ - - OFTEST(dcmdata_decimalString_1) - { -- DcmDecimalString decStr(DCM_ContourData, EVR_DS); -+ DcmDecimalString decStr(DCM_ContourData); - OFVector doubleVals; - OFCHECK(decStr.putString("1\\2.0\\3.5\\-4.99\\+500.005\\6.66E-01").good()); - OFCHECK(decStr.getFloat64Vector(doubleVals).good()); -@@ -45,7 +45,7 @@ OFTEST(dcmdata_decimalString_1) - - OFTEST(dcmdata_decimalString_2) - { -- DcmDecimalString decStr(DCM_ContourData, EVR_DS); -+ DcmDecimalString decStr(DCM_ContourData); - OFVector doubleVals; - /* insert a NULL byte into the string */ - OFCHECK(decStr.putString("1\\2.0\\3.5\\-4.99\0\\+500.005\\6.66E-01", 34).good()); -@@ -61,7 +61,7 @@ OFTEST(dcmdata_decimalString_2) - - OFTEST(dcmdata_decimalString_3) - { -- DcmDecimalString decStr(DCM_ContourData, EVR_DS); -+ DcmDecimalString decStr(DCM_ContourData); - OFVector doubleVals; - /* insert a NULL byte into the string */ - OFCHECK(decStr.putOFStringArray(OFString("1\\2.0\\3.5\\-4.99\0\\+500.005\\6.66E-01", 34)).good()); -@@ -77,7 +77,7 @@ OFTEST(dcmdata_decimalString_3) - - OFTEST(dcmdata_decimalString_4) - { -- DcmDecimalString decStr(DCM_ContourData, EVR_DS); -+ DcmDecimalString decStr(DCM_ContourData); - OFVector doubleVals; - OFCHECK(decStr.putString("1\\2.0\\3.5\\-4.99\\+500.005\\6.66E-01\\").good()); - OFCHECK_EQUAL(decStr.getVM(), 7); -@@ -96,7 +96,7 @@ OFTEST(dcmdata_decimalString_putFloat64) - { - // Test insertion in the beginning - OFString testStr; -- DcmDecimalString decStr(DCM_ContourData, EVR_DS); -+ DcmDecimalString decStr(DCM_ContourData); - OFCHECK(decStr.putFloat64(0, 0).good()); - decStr.getOFStringArray(testStr); - OFCHECK(testStr == "0"); diff --git a/debian/patches/07_dont_export_all_executables.patch b/debian/patches/07_dont_export_all_executables.patch index 8aa71984..dac3a5e0 100644 --- a/debian/patches/07_dont_export_all_executables.patch +++ b/debian/patches/07_dont_export_all_executables.patch @@ -11,7 +11,7 @@ Index: dcmtk/CMake/dcmtkMacros.cmake =================================================================== --- dcmtk.orig/CMake/dcmtkMacros.cmake +++ dcmtk/CMake/dcmtkMacros.cmake -@@ -55,11 +55,11 @@ macro(DCMTK_ADD_EXECUTABLE PROGRAM) +@@ -59,11 +59,11 @@ macro(DCMTK_ADD_EXECUTABLE PROGRAM) endif() # Collect executable as part of global DCMTK_EXECUTABLE_TARGETS property diff --git a/debian/patches/0cf6b12d8ea0b727f0fe2ab076b6f180100fbd30.patch b/debian/patches/0cf6b12d8ea0b727f0fe2ab076b6f180100fbd30.patch deleted file mode 100644 index c420e622..00000000 --- a/debian/patches/0cf6b12d8ea0b727f0fe2ab076b6f180100fbd30.patch +++ /dev/null @@ -1,178 +0,0 @@ -From 0cf6b12d8ea0b727f0fe2ab076b6f180100fbd30 Mon Sep 17 00:00:00 2001 -From: Michael Onken -Date: Thu, 25 Nov 2021 11:59:16 +0100 -Subject: [PATCH] Remove some typos in the codebase. - - * Concatentation -> Concatenation - * intialized -> initialized - * "permits to" -> "permits one to" - * "allow to" -> "allow one to" - * "allows to" -> "allows one to" - * truely -> truly - * additonal -> additional - -Thanks to GitHub user "malaterre" for the report and suggested fix. ---- - dcmfg/libsrc/concatenationcreator.cc | 2 +- - dcmfg/libsrc/concatenationloader.cc | 6 +++--- - dcmfg/tests/t_concatenation_loader.cc | 12 ++++++------ - dcmjpeg/docs/dcmcjpeg.man | 2 +- - dcmpstat/apps/dcmpsmk.cc | 2 +- - dcmpstat/docs/dcmp2pgm.man | 2 +- - dcmpstat/docs/dcmprscp.man | 2 +- - dcmpstat/docs/dcmpsmk.man | 2 +- - dcmwlm/docs/wlmscpfs.man | 2 +- - 9 files changed, 16 insertions(+), 16 deletions(-) - -Index: dcmtk/dcmfg/libsrc/concatenationcreator.cc -=================================================================== ---- dcmtk.orig/dcmfg/libsrc/concatenationcreator.cc -+++ dcmtk/dcmfg/libsrc/concatenationcreator.cc -@@ -246,7 +246,7 @@ size_t ConcatenationCreator::getNumInsta - OFCondition result = configureCommon(); - if (result.bad()) - { -- DCMFG_ERROR("Unable to compute number of instances for Concatenation, maybe input not intialized?)"); -+ DCMFG_ERROR("Unable to compute number of instances for Concatenation, maybe input not initialized?)"); - return 0; - } - } -Index: dcmtk/dcmfg/libsrc/concatenationloader.cc -=================================================================== ---- dcmtk.orig/dcmfg/libsrc/concatenationloader.cc -+++ dcmtk/dcmfg/libsrc/concatenationloader.cc -@@ -445,7 +445,7 @@ OFCondition ConcatenationLoader::insertD - char buf[100]; - dcmGenerateUniqueIdentifier(buf, SITE_INSTANCE_UID_ROOT); - uid = buf; -- DCMFG_WARN("SOP Instance UID of Concatentation Source (0020,0242) not set, created new SOP Instance UID " -+ DCMFG_WARN("SOP Instance UID of Concatenation Source (0020,0242) not set, created new SOP Instance UID " - << uid); - } - OFCondition result = m_Result->putAndInsertOFStringArray(DCM_SOPInstanceUID, uid); -@@ -551,8 +551,8 @@ void ConcatenationLoader::Info::print(OF - { - out << "Concatenation UID* : " << m_ConcatenationUID << OFendl; - out << " SOP Class UID* : " << m_SOPClassUID << OFendl; -- out << " Concatentation Source UID* : " << m_SourceUID << OFendl; -- out << " Concatentation Source File : " << m_FileConatenationSource << OFendl; -+ out << " Concatenation Source UID* : " << m_SourceUID << OFendl; -+ out << " Concatenation Source File : " << m_FileConatenationSource << OFendl; - out << " Number of Frames (computed): " << m_NumTotalFrames << OFendl; - out << " In-conc. Total Number : " << m_inConcatTotalNumber << OFendl; - out << " Patient ID : " << m_PatientID << OFendl; -Index: dcmtk/dcmfg/tests/t_concatenation_loader.cc -=================================================================== ---- dcmtk.orig/dcmfg/tests/t_concatenation_loader.cc -+++ dcmtk/dcmfg/tests/t_concatenation_loader.cc -@@ -114,8 +114,8 @@ static void prepare_scan_dump() - { - SCAN_DUMP += "Concatenation UID* : 1.3.6.1.4.1.5962.1.7.70.2.1.1166562673.14401\n"; - SCAN_DUMP += " SOP Class UID* : 1.2.840.10008.5.1.4.1.1.2.1\n"; -- SCAN_DUMP += " Concatentation Source UID* : \n"; -- SCAN_DUMP += " Concatentation Source File : \n"; -+ SCAN_DUMP += " Concatenation Source UID* : \n"; -+ SCAN_DUMP += " Concatenation Source File : \n"; - SCAN_DUMP += " Number of Frames (computed): 60\n"; - SCAN_DUMP += " In-conc. Total Number : 6\n"; - SCAN_DUMP += " Patient ID : 0070\n"; -@@ -152,8 +152,8 @@ static void prepare_scan_dump() - SCAN_DUMP += "--------------------------------------------------------------\n"; - SCAN_DUMP += "Concatenation UID* : 1.3.6.1.4.1.5962.1.7.70.2.2.1166562673.14401\n"; - SCAN_DUMP += " SOP Class UID* : 1.2.840.10008.5.1.4.1.1.2.1\n"; -- SCAN_DUMP += " Concatentation Source UID* : \n"; -- SCAN_DUMP += " Concatentation Source File : \n"; -+ SCAN_DUMP += " Concatenation Source UID* : \n"; -+ SCAN_DUMP += " Concatenation Source File : \n"; - SCAN_DUMP += " Number of Frames (computed): 30\n"; - SCAN_DUMP += " In-conc. Total Number : 3\n"; - SCAN_DUMP += " Patient ID : 0070\n"; -@@ -178,8 +178,8 @@ static void prepare_scan_dump() - SCAN_DUMP += "--------------------------------------------------------------\n"; - SCAN_DUMP += "Concatenation UID* : 1.3.6.1.4.1.5962.1.7.70.2.3.1166562673.14401\n"; - SCAN_DUMP += " SOP Class UID* : 1.2.840.10008.5.1.4.1.1.2.1\n"; -- SCAN_DUMP += " Concatentation Source UID* : \n"; -- SCAN_DUMP += " Concatentation Source File : \n"; -+ SCAN_DUMP += " Concatenation Source UID* : \n"; -+ SCAN_DUMP += " Concatenation Source File : \n"; - SCAN_DUMP += " Number of Frames (computed): 30\n"; - SCAN_DUMP += " In-conc. Total Number : 3\n"; - SCAN_DUMP += " Patient ID : 0070\n"; -Index: dcmtk/dcmjpeg/docs/dcmcjpeg.man -=================================================================== ---- dcmtk.orig/dcmjpeg/docs/dcmcjpeg.man -+++ dcmtk/dcmjpeg/docs/dcmcjpeg.man -@@ -148,7 +148,7 @@ lossless JPEG codec selection: - +tl --true-lossless - true lossless codec (default) - -- # This option selects an encoder, that guarantees truely lossless -+ # This option selects an encoder, that guarantees truly lossless - # image compression. See NOTES for further information. - - +pl --pseudo-lossless -Index: dcmtk/dcmpstat/apps/dcmpsmk.cc -=================================================================== ---- dcmtk.orig/dcmpstat/apps/dcmpsmk.cc -+++ dcmtk/dcmpstat/apps/dcmpsmk.cc -@@ -311,7 +311,7 @@ int main(int argc, char *argv[]) - /* add additional image references to pstate */ - if (cmd.getParamCount() > 2) - { -- OFLOG_INFO(dcmpsmkLogger, "adding additonal image reference(s)"); -+ OFLOG_INFO(dcmpsmkLogger, "adding additional image reference(s)"); - const int count = cmd.getParamCount(); - for (int i = 2; i < count; i++) - { -Index: dcmtk/dcmpstat/docs/dcmp2pgm.man -=================================================================== ---- dcmtk.orig/dcmpstat/docs/dcmp2pgm.man -+++ dcmtk/dcmpstat/docs/dcmp2pgm.man -@@ -19,7 +19,7 @@ a grayscale softcopy presentation state - with 8 bits/pixel. The bitmap is stored either as "Portable Gray Map" (PGM) - or as a DICOM secondary capture image object. If no presentation state is - read from file, a default presentation state is created. The utility allows --to read a configuration file of the Softcopy Presentation State Viewer upon -+one to read a configuration file of the Softcopy Presentation State Viewer upon - startup. In this case, the settings from the configuration file affecting - the rendering of the presentation state are used, e.g. a correction of the - gray scale range according to Barten's model (DICOM part 14) can be -Index: dcmtk/dcmpstat/docs/dcmprscp.man -=================================================================== ---- dcmtk.orig/dcmpstat/docs/dcmprscp.man -+++ dcmtk/dcmpstat/docs/dcmprscp.man -@@ -22,7 +22,7 @@ The \b dcmprscp utility accepts print jo - not create real hardcopies but stores print jobs in the local DICOMscope - database as a set of Stored Print objects (one per page) and Hardcopy - Grayscale images (one per film box N-SET). The DICOMscope application allows --to load a Stored Print object created by \b dcmprscp and to render a screen -+one to load a Stored Print object created by \b dcmprscp and to render a screen - preview of the hardcopy. The \b dcmprscp utility reads the characteristics of - the printer to be emulated from the configuration file. - -Index: dcmtk/dcmpstat/docs/dcmpsmk.man -=================================================================== ---- dcmtk.orig/dcmpstat/docs/dcmpsmk.man -+++ dcmtk/dcmpstat/docs/dcmpsmk.man -@@ -17,7 +17,7 @@ dcmpsmk [options] dcmfile-in dcmfile-out - The \b dcmpsmk utility reads a DICOM image file and creates a grayscale - softcopy presentation state object according to Supplement 33. The - presentation state object is written back to file. A number of command line --options allow to specify how certain constructs that might be present in -+options allow one to specify how certain constructs that might be present in - the image file should be referenced or activated in the presentation state. - The newly created presentation state references the source image and - contains values that should allow for a "reasonable" display of the image -Index: dcmtk/dcmwlm/docs/wlmscpfs.man -=================================================================== ---- dcmtk.orig/dcmwlm/docs/wlmscpfs.man -+++ dcmtk/dcmwlm/docs/wlmscpfs.man -@@ -263,7 +263,7 @@ within the given directory. By default, - This should work as a default for most applications that would like to use - request files and want to ensure unique file names. If it is desired to change - this naming scheme, the option \e --request-file-format can be used. It --permits to specify the file naming pattern used by \e --request-file-path. -+permits one to specify the file naming pattern used by \e --request-file-path. - - For flexibility, the following placeholders can be used in the pattern provided - for \e --request-file-format: diff --git a/debian/patches/1c8cca4bf6f7c92fc16f9e66faf49409c891a2b0.patch b/debian/patches/1c8cca4bf6f7c92fc16f9e66faf49409c891a2b0.patch deleted file mode 100644 index cba4aa65..00000000 --- a/debian/patches/1c8cca4bf6f7c92fc16f9e66faf49409c891a2b0.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 1c8cca4bf6f7c92fc16f9e66faf49409c891a2b0 Mon Sep 17 00:00:00 2001 -From: Marco Eichelberg -Date: Fri, 5 Feb 2021 17:50:44 +0100 -Subject: [PATCH] Adjusted the number of digits printed for FL and FD. - -Adjusted the number of digits printed for FL elements to FLT_DECIMAL_DIG -(9) instead of 8, to make sure that the printed values can be converted -back to FL without loss. Fixed comment for FD, where the values was -already correct. - -Thanks to Mathieu Malaterre for pointing -out the issue. ---- - dcmdata/libsrc/dcvrfd.cc | 8 ++++---- - dcmdata/libsrc/dcvrfl.cc | 8 ++++---- - 2 files changed, 8 insertions(+), 8 deletions(-) - -diff --git a/dcmdata/libsrc/dcvrfd.cc b/dcmdata/libsrc/dcvrfd.cc -index 72d9dd5f8..3fabe0a7f 100644 ---- a/dcmdata/libsrc/dcvrfd.cc -+++ b/dcmdata/libsrc/dcvrfd.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2020, OFFIS e.V. -+ * Copyright (C) 1994-2021, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -190,11 +190,11 @@ void DcmFloatingPointDouble::print(STD_NAMESPACE ostream &out, - { - /* check whether first value is printed (omit delimiter) */ - if (i == 0) -- OFStandard::ftoa(buffer, sizeof(buffer), *doubleVals, 0, 0, 17 /* DBL_DIG + 2 for DICOM FD */); -+ OFStandard::ftoa(buffer, sizeof(buffer), *doubleVals, 0, 0, 17 /* DBL_DECIMAL_DIG for DICOM FD */); - else - { - buffer[0] = '\\'; -- OFStandard::ftoa(buffer + 1, sizeof(buffer) - 1, *doubleVals, 0, 0, 17 /* DBL_DIG + 2 for DICOM FD */); -+ OFStandard::ftoa(buffer + 1, sizeof(buffer) - 1, *doubleVals, 0, 0, 17 /* DBL_DECIMAL_DIG for DICOM FD */); - } - /* check whether current value sticks to the length limit */ - newLength = printedLength + OFstatic_cast(unsigned long, strlen(buffer)); -@@ -273,7 +273,7 @@ OFCondition DcmFloatingPointDouble::getOFString(OFString &stringVal, - { - /* ... and convert it to a character string */ - char buffer[64]; -- OFStandard::ftoa(buffer, sizeof(buffer), doubleVal, 0, 0, 17 /* DBL_DIG + 2 for DICOM FD */); -+ OFStandard::ftoa(buffer, sizeof(buffer), doubleVal, 0, 0, 17 /* DBL_DECIMAL_DIG for DICOM FD */); - /* assign result */ - stringVal = buffer; - } -diff --git a/dcmdata/libsrc/dcvrfl.cc b/dcmdata/libsrc/dcvrfl.cc -index 5eb83fafc..0934af4f1 100644 ---- a/dcmdata/libsrc/dcvrfl.cc -+++ b/dcmdata/libsrc/dcvrfl.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2020, OFFIS e.V. -+ * Copyright (C) 1994-2021, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -192,11 +192,11 @@ void DcmFloatingPointSingle::print(STD_NAMESPACE ostream &out, - { - /* check whether first value is printed (omit delimiter) */ - if (i == 0) -- OFStandard::ftoa(buffer, sizeof(buffer), *floatVals, 0, 0, 8 /* FLT_DIG + 2 for DICOM FL */); -+ OFStandard::ftoa(buffer, sizeof(buffer), *floatVals, 0, 0, 9 /* FLT_DECIMAL_DIG for DICOM FL */); - else - { - buffer[0] = '\\'; -- OFStandard::ftoa(buffer + 1, sizeof(buffer) - 1, *floatVals, 0, 0, 8 /* FLT_DIG + 2 for DICOM FL */); -+ OFStandard::ftoa(buffer + 1, sizeof(buffer) - 1, *floatVals, 0, 0, 9 /* FLT_DECIMAL_DIG for DICOM FL */); - } - /* check whether current value sticks to the length limit */ - newLength = printedLength + OFstatic_cast(unsigned long, strlen(buffer)); -@@ -275,7 +275,7 @@ OFCondition DcmFloatingPointSingle::getOFString(OFString &value, - { - /* ... and convert it to a character string */ - char buffer[64]; -- OFStandard::ftoa(buffer, sizeof(buffer), floatVal, 0, 0, 8 /* FLT_DIG + 2 for DICOM FL */); -+ OFStandard::ftoa(buffer, sizeof(buffer), floatVal, 0, 0, 9 /* FLT_DECIMAL_DIG for DICOM FL */); - /* assign result */ - value = buffer; - } --- -2.30.2 - diff --git a/debian/patches/3ae202ee9d8f27054ad0c463a6799d8b10b4864b.patch b/debian/patches/3ae202ee9d8f27054ad0c463a6799d8b10b4864b.patch deleted file mode 100644 index 4459999c..00000000 --- a/debian/patches/3ae202ee9d8f27054ad0c463a6799d8b10b4864b.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 3ae202ee9d8f27054ad0c463a6799d8b10b4864b Mon Sep 17 00:00:00 2001 -From: Joerg Riesmeier -Date: Thu, 30 Sep 2021 13:48:42 +0200 -Subject: [PATCH] Converted non-ASCII characters to ASCII. - -Thanks to GitHub user "malaterre" for the report and suggested fix. ---- - dcmect/libsrc/enhanced_ct.cc | 4 ++-- - dcmfg/libsrc/concatenationloader.cc | 4 ++-- - dcmiod/include/dcmtk/dcmiod/modsopcommon.h | 6 +++--- - dcmseg/include/dcmtk/dcmseg/segment.h | 6 +++--- - dcmtls/include/dcmtk/dcmtls/tlsciphr.h | 6 +++--- - 5 files changed, 13 insertions(+), 13 deletions(-) - -diff --git a/dcmect/libsrc/enhanced_ct.cc b/dcmect/libsrc/enhanced_ct.cc -index 007cb8813..619374290 100644 ---- a/dcmect/libsrc/enhanced_ct.cc -+++ b/dcmect/libsrc/enhanced_ct.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2019, Open Connections GmbH -+ * Copyright (C) 2019-2021, Open Connections GmbH - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation are maintained by -@@ -480,7 +480,7 @@ OFCondition EctEnhancedCT::loadDataset(DcmDataset& dataset, EctEnhancedCT*& ct) - else - { - DCMECT_ERROR("Invalid SOP Class: " -- << sopClass << ", only Enhanced CT Image Storage (1.2.840.10008.5.1.4.1.1.2.1​) supported"); -+ << sopClass << ", only Enhanced CT Image Storage (1.2.840.10008.5.1.4.1.1.2.1) supported"); - return ECT_InvalidSOPClass; - } - } -diff --git a/dcmfg/libsrc/concatenationloader.cc b/dcmfg/libsrc/concatenationloader.cc -index 3833ddc4f..aad76f69f 100644 ---- a/dcmfg/libsrc/concatenationloader.cc -+++ b/dcmfg/libsrc/concatenationloader.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2019-2020, Open Connections GmbH -+ * Copyright (C) 2019-2021, Open Connections GmbH - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation are maintained by -@@ -445,7 +445,7 @@ OFCondition ConcatenationLoader::insertDestinationAttributes() - char buf[100]; - dcmGenerateUniqueIdentifier(buf, SITE_INSTANCE_UID_ROOT); - uid = buf; -- DCMFG_WARN("SOP Instance UID of Concatentation Source (0020,0242)​ not set, created new SOP Instance UID " -+ DCMFG_WARN("SOP Instance UID of Concatentation Source (0020,0242) not set, created new SOP Instance UID " - << uid); - } - OFCondition result = m_Result->putAndInsertOFStringArray(DCM_SOPInstanceUID, uid); -diff --git a/dcmiod/include/dcmtk/dcmiod/modsopcommon.h b/dcmiod/include/dcmtk/dcmiod/modsopcommon.h -index fab033e3f..27f433ad2 100644 ---- a/dcmiod/include/dcmtk/dcmiod/modsopcommon.h -+++ b/dcmiod/include/dcmtk/dcmiod/modsopcommon.h -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2015-2019, Open Connections GmbH -+ * Copyright (C) 2015-2021, Open Connections GmbH - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation are maintained by -@@ -177,8 +177,8 @@ public: - - /** Set Timezone Offset From UTC - * @param value Value to be set (single value only) or "" for no value. -- * Encoded as an ASCII string in the format “&ZZXX”. The components of this -- * string, from left to right, are & = “+” or “-”, and ZZ = Hours and -+ * Encoded as an ASCII string in the format "&ZZXX". The components of this -+ * string, from left to right, are & = "+" or "-", and ZZ = Hours and - * XX = Minutes of offset. - * @param checkValue Check 'value' for conformance with VR (SH) and VM (1) if enabled - * @return EC_Normal if successful, an error code otherwise -diff --git a/dcmseg/include/dcmtk/dcmseg/segment.h b/dcmseg/include/dcmtk/dcmseg/segment.h -index f7987c0c9..8c887a531 100644 ---- a/dcmseg/include/dcmtk/dcmseg/segment.h -+++ b/dcmseg/include/dcmtk/dcmseg/segment.h -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2015-2019, Open Connections GmbH -+ * Copyright (C) 2015-2021, Open Connections GmbH - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation are maintained by -@@ -58,10 +58,10 @@ public: - * successful; memory is allocated by the function - * @param segmentLabel Free text label for the segment - * @param segmentedPropertyCategory The segmented property category. -- * Baseline CID 7150 “Segmentation Property Categories” should be -+ * Baseline CID 7150 "Segmentation Property Categories" should be - * used. - * @param segmentedPropertyType The segmented property type. Baseline CID -- * 7151 “Segmentation Property Types” -+ * 7151 "Segmentation Property Types" - * @param algoType The algorithm type used for segmenting this segment - * @param algoName Algorithm name (required if algoType is not MANUAL) - * @return EC_Normal if creation was successful, error otherwise -diff --git a/dcmtls/include/dcmtk/dcmtls/tlsciphr.h b/dcmtls/include/dcmtk/dcmtls/tlsciphr.h -index 6ffd4a962..c3ad28794 100644 ---- a/dcmtls/include/dcmtk/dcmtls/tlsciphr.h -+++ b/dcmtls/include/dcmtk/dcmtls/tlsciphr.h -@@ -132,7 +132,7 @@ enum DcmTLSCipherKeyExchange - /// Static RSA key exchange - TKE_RSA, - -- /// Elliptic Curve Diffie–Hellman -+ /// Elliptic Curve Diffie-Hellman - TKE_ECDH, - - /// Fixed ECDH with ECDSA-signed certificates -@@ -141,7 +141,7 @@ enum DcmTLSCipherKeyExchange - /// Fixed ECDH with RSA signatures - TKE_ECDH_RSA, - -- /// Diffie–Hellman key exchange -+ /// Diffie-Hellman key exchange - TKE_DH - - }; -@@ -157,7 +157,7 @@ enum DcmTLSCipherAuthentication - /// Digital Signature Standard - TCA_DSS, - -- /// Elliptic Curve Diffie–Hellman -+ /// Elliptic Curve Diffie-Hellman - TCA_ECDH, - - /// Elliptic Curve Digital Signature Algorithm --- -2.30.2 - diff --git a/debian/patches/ab61e8577ff0974efcfae2907c48baf6023c1160.patch b/debian/patches/ab61e8577ff0974efcfae2907c48baf6023c1160.patch deleted file mode 100644 index 753437a8..00000000 --- a/debian/patches/ab61e8577ff0974efcfae2907c48baf6023c1160.patch +++ /dev/null @@ -1,25 +0,0 @@ -From ab61e8577ff0974efcfae2907c48baf6023c1160 Mon Sep 17 00:00:00 2001 -From: Joerg Riesmeier -Date: Thu, 30 Sep 2021 13:08:23 +0200 -Subject: [PATCH] Replaced German umlaut by its transliteration. - -Replaced German umlaut in code meaning by its transliteration. - -Thanks to GitHub user "malaterre" for the report. ---- - dcmsr/include/dcmtk/dcmsr/codes/dcm.h | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -Index: dcmtk/dcmsr/include/dcmtk/dcmsr/codes/dcm.h -=================================================================== ---- dcmtk.orig/dcmsr/include/dcmtk/dcmsr/codes/dcm.h -+++ dcmtk/dcmsr/include/dcmtk/dcmsr/codes/dcm.h -@@ -1630,7 +1630,7 @@ - #define CODE_DCM_Generic3DPlanning DSRBasicCodedEntry("112341", "DCM", "Generic 3D Planning") - #define CODE_DCM_GenericPlanningForHipReplacement DSRBasicCodedEntry("112342", "DCM", "Generic Planning for Hip Replacement") - #define CODE_DCM_GenericPlanningForKneeReplacement DSRBasicCodedEntry("112343", "DCM", "Generic Planning for Knee Replacement") --#define CODE_DCM_MuellerMethodPlanningForHipReplacement DSRBasicCodedEntry("112344", "DCM", "Müller Method Planning for Hip Replacement") -+#define CODE_DCM_MuellerMethodPlanningForHipReplacement DSRBasicCodedEntry("112344", "DCM", "Mueller Method Planning for Hip Replacement") - #define CODE_DCM_ImplantationPlan DSRBasicCodedEntry("112345", "DCM", "Implantation Plan") - #define CODE_DCM_SelectedImplantComponent DSRBasicCodedEntry("112346", "DCM", "Selected Implant Component") - #define CODE_DCM_ComponentID DSRBasicCodedEntry("112347", "DCM", "Component ID") diff --git a/debian/patches/bigendian.patch b/debian/patches/bigendian.patch deleted file mode 100644 index 007020e7..00000000 --- a/debian/patches/bigendian.patch +++ /dev/null @@ -1,102 +0,0 @@ -Author: Mathieu Malaterre -Description: Fix unit test suite on big endian machine - Concatenation of upstream commits: - . - - b499d89e769feffce03c5d7cefa1cb06d33a2b5b - - 9e8434a2952ae39d1f9d0914173b5cc5b1b32175 - - 4df0f42790b9952aa75c7242fbcc47a348922bc6 -Forwarded: not-needed - -Index: dcmtk/dcmect/tests/t_roundtrip.cc -=================================================================== ---- dcmtk.orig/dcmect/tests/t_roundtrip.cc -+++ dcmtk/dcmect/tests/t_roundtrip.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2019-2020, OFFIS e.V. -+ * Copyright (C) 2019-2021, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -28,6 +28,9 @@ - - #include "dcmtk/dcmect/enhanced_ct.h" - -+#include "dcmtk/dcmdata/dcxfer.h" -+#include "dcmtk/dcmdata/dcswap.h" -+ - #include "dcmtk/dcmfg/concatenationcreator.h" - #include "dcmtk/dcmfg/concatenationloader.h" - #include "dcmtk/dcmfg/fgctacquisitiondetails.h" -@@ -295,7 +298,6 @@ static void addSharedFGs(EctEnhancedCT* - OFCHECK(exp_item->setCTDIVol(0.1).good()); - CodeSequenceMacro* phantom_item = new CodeSequenceMacro("113682", "DCM", "ACR Accreditation Phantom - CT"); - exp_item->getCTDIPhantomTypeCodeSequence().push_back(phantom_item); -- OFCHECK(exp_item->setEstimatedDoseSaving(0.2).good()); - OFCHECK(exp_item->setExposureInMas(0.3).good()); - OFCHECK(exp_item->setExposureModulationType("WEIRD").good()); - OFCHECK(exp_item->setExposureTimeInMs(0.4).good()); -@@ -619,6 +621,7 @@ static void checkConcatenationInstance(s - // Check that all pixels are set to their original source instances frame number (starting from 1) - for (size_t pix = 0; pix < NUM_PIXELS_PER_FRAME; pix++) - { -+ swapIfNecessary(gLocalByteOrder, EBO_LittleEndian, &frame[pix], 2, sizeof(Uint16)); - OFCHECK(frame[pix] == numInstance + 1); - } - delete concat; -@@ -658,7 +661,11 @@ static void prepareExpectedDump() - { - EXPECTED_DUMP += "\n"; - EXPECTED_DUMP += "# Dicom-Data-Set\n"; -- EXPECTED_DUMP += "# Used TransferSyntax: Little Endian Explicit\n"; -+ // DcmDataset.print() produces dumps in local endianess, so make sure the dump reflects the current machine -+ if (gLocalByteOrder == EBO_LittleEndian) -+ EXPECTED_DUMP += "# Used TransferSyntax: Little Endian Explicit\n"; -+ else -+ EXPECTED_DUMP += "# Used TransferSyntax: Big Endian Explicit\n"; - EXPECTED_DUMP += "(0008,0008) CS [ORIGINAL\\PRIMARY\\VOLUME\\MAXIMUM] # 32, 4 ImageType\n"; - EXPECTED_DUMP += "(0008,0016) UI =EnhancedCTImageStorage # 28, 1 SOPClassUID\n"; - EXPECTED_DUMP -@@ -789,7 +796,7 @@ static void prepareExpectedDump() - EXPECTED_DUMP += " (fffe,e00d) na (ItemDelimitationItem for re-encoding) # 0, 0 ItemDelimitationItem\n"; - EXPECTED_DUMP += " (fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem\n"; - EXPECTED_DUMP += " (0018,9321) SQ (Sequence with explicit length #=1) # 0, 1 CTExposureSequence\n"; -- EXPECTED_DUMP += " (fffe,e000) na (Item with explicit length #=10) # 0, 1 Item\n"; -+ EXPECTED_DUMP += " (fffe,e000) na (Item with explicit length #=9) # 0, 1 Item\n"; - EXPECTED_DUMP += " (0018,115e) DS [0.5] # 4, 1 " - "ImageAndFluoroscopyAreaDoseProduct\n"; - EXPECTED_DUMP -@@ -807,7 +814,6 @@ static void prepareExpectedDump() - += " (fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem\n"; - EXPECTED_DUMP - += " (0018,9323) CS [WEIRD] # 6, 1 ExposureModulationType\n"; -- EXPECTED_DUMP += " (0018,9324) FD 0.2 # 8, 1 EstimatedDoseSaving\n"; - EXPECTED_DUMP += " (0018,9328) FD 0.4 # 8, 1 ExposureTimeInms\n"; - EXPECTED_DUMP += " (0018,9330) FD 0.7 # 8, 1 XRayTubeCurrentInmA\n"; - EXPECTED_DUMP += " (0018,9332) FD 0.3 # 8, 1 ExposureInmAs\n"; -Index: dcmtk/dcmseg/tests/troundtrip.cc -=================================================================== ---- dcmtk.orig/dcmseg/tests/troundtrip.cc -+++ dcmtk/dcmseg/tests/troundtrip.cc -@@ -31,6 +31,7 @@ - #include "dcmtk/dcmfg/fgplanpo.h" - #include "dcmtk/dcmfg/fgseg.h" - #include "dcmtk/dcmiod/iodmacro.h" -+#include "dcmtk/dcmdata/dcxfer.h" - #include "dcmtk/ofstd/ofmem.h" - #include "dcmtk/ofstd/ofstrutl.h" - #include "dcmtk/ofstd/oftempf.h" -@@ -406,7 +407,11 @@ static void prepareExpectedDump() - { - EXPECTED_DUMP = "\n"; - EXPECTED_DUMP += "# Dicom-Data-Set\n"; -- EXPECTED_DUMP += "# Used TransferSyntax: Little Endian Explicit\n"; -+ // DcmDataset.print() produces dumps in local endianess, so make sure the dump reflects the current machine -+ if (gLocalByteOrder == EBO_LittleEndian) -+ EXPECTED_DUMP += "# Used TransferSyntax: Little Endian Explicit\n"; -+ else -+ EXPECTED_DUMP += "# Used TransferSyntax: Big Endian Explicit\n"; - EXPECTED_DUMP += "(0008,0008) CS [DERIVED\\PRIMARY] # 16, 2 ImageType\n"; - EXPECTED_DUMP += "(0008,0016) UI =SegmentationStorage # 28, 1 SOPClassUID\n"; - EXPECTED_DUMP diff --git a/debian/patches/bug1000220.patch b/debian/patches/bug1000220.patch deleted file mode 100644 index 68c27ac5..00000000 --- a/debian/patches/bug1000220.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 8f6c9ba05eb146310a6325fb8ab18dfb14c1a291 Mon Sep 17 00:00:00 2001 -From: Joerg Riesmeier -Date: Mon, 22 Nov 2021 18:54:35 +0100 -Subject: [PATCH] Replaced OFListIterator by OFListConstIterator. - -Replaced type of iterator variable to OFListConstIterator to avoid -compiler errors reported by gcc when compiling DICOMscope with STL -and C++14 support enabled. - -Thanks to GitHub user "malaterre" for the report and suggested fix. ---- - dcmsr/include/dcmtk/dcmsr/dsrtlist.h | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/dcmsr/include/dcmtk/dcmsr/dsrtlist.h b/dcmsr/include/dcmtk/dcmsr/dsrtlist.h -index 5ec109aca..31759b851 100644 ---- a/dcmsr/include/dcmtk/dcmsr/dsrtlist.h -+++ b/dcmsr/include/dcmtk/dcmsr/dsrtlist.h -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2000-2018, OFFIS e.V. -+ * Copyright (C) 2000-2021, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -282,7 +282,7 @@ template class DSRListOfItems - ItemList.push_back(item); - result = EC_Normal; - } else { -- OFLIST_TYPENAME OFListIterator(T) iterator = ItemList.begin(); -+ OFLIST_TYPENAME OFListConstIterator(T) iterator = ItemList.begin(); - if (gotoItemPos(idx, iterator)) - { - ItemList.insert(iterator, 1, item); -@@ -299,7 +299,7 @@ template class DSRListOfItems - OFCondition removeItem(const size_t idx) - { - OFCondition result = EC_IllegalParameter; -- OFLIST_TYPENAME OFListIterator(T) iterator = ItemList.begin(); -+ OFLIST_TYPENAME OFListConstIterator(T) iterator = ItemList.begin(); - if (gotoItemPos(idx, iterator)) - { - ItemList.erase(iterator); diff --git a/debian/patches/da5370947226783ce3548bf1e5b7112fac70de46.patch b/debian/patches/da5370947226783ce3548bf1e5b7112fac70de46.patch deleted file mode 100644 index ba84c571..00000000 --- a/debian/patches/da5370947226783ce3548bf1e5b7112fac70de46.patch +++ /dev/null @@ -1,57 +0,0 @@ -From da5370947226783ce3548bf1e5b7112fac70de46 Mon Sep 17 00:00:00 2001 -From: Joerg Riesmeier -Date: Wed, 8 Nov 2023 11:38:54 +0100 -Subject: [PATCH] Fixed issue with delimiters being converted. - -Fixed issue with delimiter character "\" being converted when converting -a DICOM dataset that uses a Specific Character Set of "ISO 2022 IR 13\ISO -2022 IR 87" to UTF-8. The delimiter "\" was incorrectly converted to the -Yen sign when processing the value of an "LO" data element that contains -multiple values but does not use any escape sequences. This issues has -been fixed now by always treating the delimiters in a special way. - -Thanks to Mathieu Malaterre for the report -and David Gobbi for the analysis and testing. ---- - dcmdata/libsrc/dcspchrs.cc | 14 ++++++++------ - 1 file changed, 8 insertions(+), 6 deletions(-) - -diff --git a/dcmdata/libsrc/dcspchrs.cc b/dcmdata/libsrc/dcspchrs.cc -index c327a1aa8..69d14a160 100644 ---- a/dcmdata/libsrc/dcspchrs.cc -+++ b/dcmdata/libsrc/dcspchrs.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2011-2022, OFFIS e.V. -+ * Copyright (C) 2011-2023, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -548,8 +548,9 @@ OFCondition DcmSpecificCharacterSet::convertString(const char *fromString, - const OFString &delimiters) - { - OFCondition status = EC_Normal; -- // check whether there are any code extensions at all -- if (EncodingConverters.empty() || !checkForEscapeCharacter(fromString, fromLength)) -+ // check whether there are or could be any code extensions -+ const OFBool hasEscapeChar = checkForEscapeCharacter(fromString, fromLength); -+ if (EncodingConverters.empty() || (!hasEscapeChar && delimiters.empty())) - { - DCMDATA_DEBUG("DcmSpecificCharacterSet: Converting '" - << convertToLengthLimitedOctalString(fromString, fromLength) << "'"); -@@ -564,10 +565,11 @@ OFCondition DcmSpecificCharacterSet::convertString(const char *fromString, - } else { - DCMDATA_DEBUG("DcmSpecificCharacterSet: Converting '" - << convertToLengthLimitedOctalString(fromString, fromLength) -- << "' (with code extensions and delimiters '" << delimiters << "')"); -+ << "' (with " << (hasEscapeChar ? "code extensions and " : "") -+ << "delimiters '" << delimiters << "')"); - } -- // code extensions according to ISO 2022 used, so we need to check for -- // particular escape sequences in order to switch between character sets -+ // code extensions according to ISO 2022 (possibly) used, so we need to check -+ // for particular escape sequences in order to switch between character sets - toString.clear(); - size_t pos = 0; - // some (extended) character sets use more than 1 byte per character diff --git a/debian/patches/f06a867513524664a1b03dfcf812d8b60fdd02cc.patch b/debian/patches/f06a867513524664a1b03dfcf812d8b60fdd02cc.patch deleted file mode 100644 index f0f0d5e9..00000000 --- a/debian/patches/f06a867513524664a1b03dfcf812d8b60fdd02cc.patch +++ /dev/null @@ -1,252 +0,0 @@ -From f06a867513524664a1b03dfcf812d8b60fdd02cc Mon Sep 17 00:00:00 2001 -From: Marco Eichelberg -Date: Fri, 6 May 2022 17:30:02 +0200 -Subject: [PATCH] Fixed path traversal vulnerability. - -Thanks to Sharon Brizinov >sharon.b@claroty.com> and Noam Moshe from -Claroty Research for the bug report and sample files. - -This closes DCMTK issue #1021. ---- - dcmnet/apps/movescu.cc | 3 ++- - dcmnet/apps/storescp.cc | 8 +++++-- - dcmnet/libsrc/dstorscp.cc | 5 ++++- - dcmnet/libsrc/scu.cc | 1 + - ofstd/include/dcmtk/ofstd/ofstd.h | 18 +++++++++++++++- - ofstd/libsrc/offname.cc | 19 ++++++++++------- - ofstd/libsrc/ofstd.cc | 35 ++++++++++++++++++++++++++++++- - 7 files changed, 76 insertions(+), 13 deletions(-) - -diff --git a/dcmnet/apps/movescu.cc b/dcmnet/apps/movescu.cc -index 40f41674c..7e444d46b 100644 ---- a/dcmnet/apps/movescu.cc -+++ b/dcmnet/apps/movescu.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1994-2021, OFFIS e.V. -+ * Copyright (C) 1994-2022, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -1425,6 +1425,7 @@ static OFCondition storeSCP( - sprintf(imageFileName, "%s.%s", - dcmSOPClassUIDToModality(req->AffectedSOPClassUID), - req->AffectedSOPInstanceUID); -+ OFStandard::sanitizeFilename(imageFileName); - } - - OFString temp_str; -diff --git a/dcmnet/apps/storescp.cc b/dcmnet/apps/storescp.cc -index ee53f2887..68b7b4e97 100644 ---- a/dcmnet/apps/storescp.cc -+++ b/dcmnet/apps/storescp.cc -@@ -1853,12 +1853,14 @@ storeSCPCallback( - if (!subdirectoryName.empty()) - subdirectoryName += '_'; - subdirectoryName += currentStudyInstanceUID; -+ OFStandard::sanitizeFilename(subdirectoryName); - break; - case ESM_PatientName: - // pattern: "[Patient's Name]_[YYYYMMDD]_[HHMMSSMMM]" - subdirectoryName = currentPatientName; - subdirectoryName += '_'; - subdirectoryName += timestamp; -+ OFStandard::sanitizeFilename(subdirectoryName); - break; - case ESM_None: - break; -@@ -2065,9 +2067,11 @@ static OFCondition storeSCP( - } - else - { -- // don't create new UID, use the study instance UID as found in object -+ // Use the SOP instance UID as found in the C-STORE request message as part of the filename -+ OFString uid = req->AffectedSOPInstanceUID; -+ OFStandard::sanitizeFilename(uid); - sprintf(imageFileName, "%s%c%s.%s%s", opt_outputDirectory.c_str(), PATH_SEPARATOR, dcmSOPClassUIDToModality(req->AffectedSOPClassUID, "UNKNOWN"), -- req->AffectedSOPInstanceUID, opt_fileNameExtension.c_str()); -+ uid.c_str(), opt_fileNameExtension.c_str()); - } - } - -diff --git a/dcmnet/libsrc/dstorscp.cc b/dcmnet/libsrc/dstorscp.cc -index e491ae5ea..1811846a2 100644 ---- a/dcmnet/libsrc/dstorscp.cc -+++ b/dcmnet/libsrc/dstorscp.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2013-2021, OFFIS e.V. -+ * Copyright (C) 2013-2022, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -425,6 +425,7 @@ OFCondition DcmStorageSCP::generateDirAndFilename(OFString &filename, - generatedFileName = tmpString; - OFSTRINGSTREAM_FREESTR(tmpString); - // combine the generated file name with the directory name -+ OFStandard::sanitizeFilename(generatedFileName); - OFStandard::combineDirAndFilename(filename, directoryName, generatedFileName); - } - break; -@@ -441,6 +442,7 @@ OFCondition DcmStorageSCP::generateDirAndFilename(OFString &filename, - generatedFileName = tmpString; - OFSTRINGSTREAM_FREESTR(tmpString); - // combine the generated file name with the directory name -+ OFStandard::sanitizeFilename(generatedFileName); - OFStandard::combineDirAndFilename(filename, directoryName, generatedFileName); - break; - } -@@ -469,6 +471,7 @@ OFCondition DcmStorageSCP::generateDirAndFilename(OFString &filename, - generatedFileName = tmpString; - OFSTRINGSTREAM_FREESTR(tmpString); - // combine the generated file name -+ OFStandard::sanitizeFilename(generatedFileName); - OFStandard::combineDirAndFilename(filename, directoryName, generatedFileName); - } else - status = EC_CouldNotGenerateFilename; -diff --git a/dcmnet/libsrc/scu.cc b/dcmnet/libsrc/scu.cc -index 34b252553..1cc9c3a46 100644 ---- a/dcmnet/libsrc/scu.cc -+++ b/dcmnet/libsrc/scu.cc -@@ -1418,6 +1418,7 @@ OFString DcmSCU::createStorageFilename(DcmDataset* dataset) - OFString name = dcmSOPClassUIDToModality(sopClassUID.c_str(), "UNKNOWN"); - name += "."; - name += sopInstanceUID; -+ OFStandard::sanitizeFilename(name); - OFString returnStr; - OFStandard::combineDirAndFilename(returnStr, m_storageDir, name, OFTrue); - return returnStr; -diff --git a/ofstd/include/dcmtk/ofstd/ofstd.h b/ofstd/include/dcmtk/ofstd/ofstd.h -index 1548e26d0..56054ccb0 100644 ---- a/ofstd/include/dcmtk/ofstd/ofstd.h -+++ b/ofstd/include/dcmtk/ofstd/ofstd.h -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2000-2021, OFFIS e.V. -+ * Copyright (C) 2000-2022, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -1165,6 +1165,22 @@ class DCMTK_OFSTD_EXPORT OFStandard - */ - static void forceSleep(Uint32 seconds); - -+ /** sanitize a filename (NOT a path name!) by replacing all path -+ * separators with underscores. This avoids possible path traversal -+ * vulnerabilities if malformed data read from file or received over -+ * a network is used as part of a filename. -+ * @param fname filename to be sanitized -+ */ -+ static void sanitizeFilename(OFString& fname); -+ -+ /** sanitize a filename (NOT a path name!) by replacing all path -+ * separators with underscores. This avoids possible path traversal -+ * vulnerabilities if malformed data read from file or received over -+ * a network is used as part of a filename. -+ * @param fname filename to be sanitized -+ */ -+ static void sanitizeFilename(char *fname); -+ - private: - - /** private implementation of strlcpy. Called when strlcpy -diff --git a/ofstd/libsrc/offname.cc b/ofstd/libsrc/offname.cc -index 832376189..a56a7e1b5 100644 ---- a/ofstd/libsrc/offname.cc -+++ b/ofstd/libsrc/offname.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 1997-2021, OFFIS e.V. -+ * Copyright (C) 1997-2022, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -73,18 +73,23 @@ OFBool OFFilenameCreator::makeFilename(unsigned int &seed, const char *dir, cons - { - // create filename - filename.clear(); -- if (dir) -- { -- filename = dir; -- filename += PATH_SEPARATOR; -- } -- if (prefix) filename += prefix; -+ if (prefix) filename = prefix; - addLongToString(creation_time, filename); - // on some systems OFrand_r may produce only 16-bit random numbers. - // To be on the safe side, we use two random numbers for the upper and the lower 16 bits. - addLongToString((((OFrand_r(seed) & 0xFFFF) << 16) | (OFrand_r(seed) & 0xFFFF)), filename); - if (postfix) filename += postfix; - -+ OFStandard::sanitizeFilename(filename); -+ -+ if (dir) -+ { -+ OFString dirname = dir; -+ dirname += PATH_SEPARATOR; -+ dirname += filename; -+ filename = dirname; -+ } -+ - // check if filename exists - stat_result = stat(filename.c_str(), &stat_buf); - if (stat_result == 0) -diff --git a/ofstd/libsrc/ofstd.cc b/ofstd/libsrc/ofstd.cc -index ae1466a9f..33ecd7954 100644 ---- a/ofstd/libsrc/ofstd.cc -+++ b/ofstd/libsrc/ofstd.cc -@@ -1,6 +1,6 @@ - /* - * -- * Copyright (C) 2001-2021, OFFIS e.V. -+ * Copyright (C) 2001-2022, OFFIS e.V. - * All rights reserved. See COPYRIGHT file for details. - * - * This software and supporting documentation were developed by -@@ -3245,6 +3245,39 @@ void OFStandard::forceSleep(Uint32 seconds) - } - } - -+ -+void OFStandard::sanitizeFilename(OFString& fname) -+{ -+ size_t len = fname.length(); -+ for (size_t i=0; i Forwarded: not-needed Last-Update: 2023-11-06 + Index: dcmtk/CMake/GenerateDCMTKConfigure.cmake =================================================================== --- dcmtk.orig/CMake/GenerateDCMTKConfigure.cmake +++ dcmtk/CMake/GenerateDCMTKConfigure.cmake -@@ -202,8 +202,8 @@ else() +@@ -195,7 +195,7 @@ else() # Modify the installation paths for configuration files, data files and documents # by adding a subdirectory with the DCMTK name and version number -- set(CMAKE_INSTALL_FULL_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/dcmtk-${DCMTK_COMPLETE_PACKAGE_VERSION}") -- set(CMAKE_INSTALL_FULL_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/dcmtk-${DCMTK_COMPLETE_PACKAGE_VERSION}") -+ set(CMAKE_INSTALL_FULL_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/dcmtk") -+ set(CMAKE_INSTALL_FULL_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/dcmtk") - set(CMAKE_INSTALL_FULL_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}-${DCMTK_COMPLETE_PACKAGE_VERSION}") +- set(CMAKE_INSTALL_SYSCONFDIR "${CMAKE_INSTALL_SYSCONFDIR}/dcmtk-${DCMTK_COMPLETE_PACKAGE_VERSION}") ++ set(CMAKE_INSTALL_SYSCONFDIR "${CMAKE_INSTALL_SYSCONFDIR}/dcmtk") + set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/dcmtk-${DCMTK_COMPLETE_PACKAGE_VERSION}") + set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DOCDIR}-${DCMTK_COMPLETE_PACKAGE_VERSION}") - # These variables are defined as macros in osconfig.h and must end with a path separator diff --git a/debian/patches/series b/debian/patches/series index d9c6a6a1..8634d570 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,18 +1,4 @@ 01_dcmtk_3.6.0-1.patch #03_datadic_install.patch 07_dont_export_all_executables.patch -#bigendian.patch -#bug1000220.patch -#test_failures.patch -#3ae202ee9d8f27054ad0c463a6799d8b10b4864b.patch -#0cf6b12d8ea0b727f0fe2ab076b6f180100fbd30.patch -#ab61e8577ff0974efcfae2907c48baf6023c1160.patch -#1c8cca4bf6f7c92fc16f9e66faf49409c891a2b0.patch -#f06a867513524664a1b03dfcf812d8b60fdd02cc.patch remove_version.patch -da5370947226783ce3548bf1e5b7112fac70de46.patch -0001-Fixed-unchecked-typecasts-of-DcmItem-search-results.patch -0002-Fixed-unchecked-typecasts-and-fixed-LUT-handling.patch -0003-Fixed-wrong-error-handling-previous-commit.patch -0004-Fixed-two-segmentation-faults.patch -0005-Fixed-DcmDecimalString-unit-tests.patch diff --git a/debian/patches/test_failures.patch b/debian/patches/test_failures.patch deleted file mode 100644 index 9f063aa8..00000000 --- a/debian/patches/test_failures.patch +++ /dev/null @@ -1,195 +0,0 @@ -Author: Mathieu Malaterre -Description: Fix random failure of unit test - Concatenation of upstream commits: - . - - cfbdf2748a9291d4d6170518b43d1d4258f8b272 - - 21eda2341946527f2f01e2be2b8a3a8e66a415f6 - - 0832266a6522214d191dc12771ff865ee9d07251 -Forwarded: not-needed - -Index: dcmtk/dcmtls/tests/tscuscptls.cc -=================================================================== ---- dcmtk.orig/dcmtls/tests/tscuscptls.cc -+++ dcmtk/dcmtls/tests/tscuscptls.cc -@@ -17,7 +17,7 @@ - * - * Purpose: TLS test for classes DcmSCP and DcmSCPPool - * -- * Note: This test will fail after 2029-02-25 due to certificate expiry. -+ * Note: This test will fail after 2029-02-25 due to certificate expiry. - * The keys embedded in this file should be replaced then (see below). - * - */ -@@ -28,6 +28,7 @@ - #include "dcmtk/ofstd/ofstdinc.h" - #include "dcmtk/ofstd/oftest.h" - #include "dcmtk/ofstd/oftimer.h" -+#include "dcmtk/ofstd/ofrand.h" - #include "dcmtk/oflog/consap.h" - #include "dcmtk/dcmnet/scp.h" - #include "dcmtk/dcmnet/scu.h" -@@ -37,6 +38,11 @@ - - #ifdef WITH_THREADS - -+#define BAILOUT(msg) do { \ -+ OFCHECK_FAIL(msg); \ -+ return; \ -+} while (0) -+ - /** Method that ensures that the current thread is actually sleeping for the - * defined number of seconds (at least). - * The problem with the regular sleep() function called from OFStandard::sleep -@@ -72,7 +78,8 @@ struct TestSCP: DcmSCP, OFThread - DcmSCP(), - m_listen_result(EC_NotYetImplemented), // value indicating "not set" - m_set_stop_after_assoc(OFFalse), -- m_set_stop_after_timeout(OFFalse) -+ m_set_stop_after_timeout(OFFalse), -+ m_is_running(OFFalse) - { - } - -@@ -83,6 +90,7 @@ struct TestSCP: DcmSCP, OFThread - m_listen_result = EC_NotYetImplemented; - m_set_stop_after_assoc = OFFalse; - m_set_stop_after_timeout = OFFalse; -+ m_is_running = OFFalse; - } - - /** Overwrite method from DcmSCP in order to test feature to stop after current -@@ -109,12 +117,16 @@ struct TestSCP: DcmSCP, OFThread - OFBool m_set_stop_after_assoc; - /// If set, the SCP should stop after TCP timeout occurred in non-blocking mode - OFBool m_set_stop_after_timeout; -+ /// indicates whether the thread is currently running -+ volatile OFBool m_is_running; - - /** Method called by OFThread to start SCP operation. Starts listen() loop of DcmSCP. - */ - virtual void run() - { -+ m_is_running = OFTrue; - m_listen_result = listen(); -+ m_is_running = OFFalse; - } - - }; -@@ -123,11 +135,22 @@ struct TestSCP: DcmSCP, OFThread - - struct TestPool : DcmSCPPool<>, OFThread - { -- OFCondition result; -+ OFCondition m_listen_result; -+ volatile OFBool m_is_running; -+ -+ TestPool() -+ : DcmSCPPool<>() -+ , OFThread() -+ , m_listen_result(EC_NotYetImplemented) -+ , m_is_running(OFFalse) -+ { } -+ - protected: - void run() - { -- result = listen(); -+ m_is_running = OFTrue; -+ m_listen_result = listen(); -+ m_is_running = OFFalse; - } - }; - -@@ -300,9 +323,9 @@ OFTEST_FLAGS(dcmtls_scp_tls, EF_None) - scpTlsLayer.setCertificateVerification(DCV_ignoreCertificate); - - /// Init and run Scp server with tls -+ OFRandom rnd; - TestSCP scp; - DcmSCPConfig& config = scp.getConfig(); -- config.setPort(11112); - config.setAETitle("ACCEPTOR"); - config.setACSETimeout(30); - config.setConnectionTimeout(1); -@@ -315,10 +338,24 @@ OFTEST_FLAGS(dcmtls_scp_tls, EF_None) - OFCHECK(config.addPresentationContext(UID_VerificationSOPClass, xfers, ASC_SC_ROLE_SCP).good()); - - config.setTransportLayer(&scpTlsLayer); -- scp.start(); - - // Ensure server is up and listening -- force_sleep(1); -+ int i = 0; -+ Uint16 port_number = 0; -+ OFMutex memory_barrier; -+ do -+ { -+ // generate a random port number between 61440 (0xF000) and 65535 -+ port_number = 0xF000 + (rnd.getRND16() & 0xFFF); -+ config.setPort(port_number); -+ scp.start(); -+ force_sleep(2); // wait 2 seconds for the SCP process to start -+ memory_barrier.lock(); -+ memory_barrier.unlock(); -+ } -+ while ((i++ < 5) && (! scp.m_is_running)); // try up to 5 port numbers before giving up -+ -+ if (! scp.m_is_running) BAILOUT("Start of the SCP thread failed: " << scp.m_listen_result.text()); - - // Configure SCU and run it against SCP - DcmTLSSCU scu; -@@ -329,7 +366,7 @@ OFTEST_FLAGS(dcmtls_scp_tls, EF_None) - scu.setPeerAETitle("ACCEPTOR"); - scu.setAETitle("REQUESTOR"); - scu.setPeerHostName("localhost"); -- scu.setPeerPort(11112); -+ scu.setPeerPort(port_number); - - scu.enableAuthentication(PRIVATE_KEY_FILENAME, PUBLIC_SELFSIGNED_CERT_FILENAME, PRIVATE_KEY_PWD, DCF_Filetype_PEM, DCF_Filetype_PEM); - scu.setPeerCertVerification(DCV_ignoreCertificate); -@@ -368,9 +405,9 @@ OFTEST_FLAGS(dcmtls_scp_pool_tls, EF_Non - scpTlsLayer.setCertificateVerification(DCV_ignoreCertificate); - - /// Init and run Scp server with tls -+ OFRandom rnd; - TestPool pool; - DcmSCPConfig& config = pool.getConfig(); -- config.setPort(11112); - config.setAETitle("ACCEPTOR"); - config.setACSETimeout(30); - config.setConnectionTimeout(1); -@@ -383,10 +420,23 @@ OFTEST_FLAGS(dcmtls_scp_pool_tls, EF_Non - OFCHECK(config.addPresentationContext(UID_VerificationSOPClass, xfers, ASC_SC_ROLE_DEFAULT).good()); - config.setTransportLayer(&scpTlsLayer); - pool.setMaxThreads(20); -- pool.start(); - - // Ensure server is up and listening -- force_sleep(1); -+ int i = 0; -+ Uint16 port_number = 0; -+ OFMutex memory_barrier; -+ do -+ { -+ // generate a random port number between 61440 (0xF000) and 65535 -+ port_number = 0xF000 + (rnd.getRND16() & 0xFFF); -+ config.setPort(port_number); -+ pool.start(); -+ force_sleep(2); // wait 2 seconds for the SCP process to start -+ memory_barrier.lock(); -+ memory_barrier.unlock(); -+ } -+ while ((i++ < 5) && (! pool.m_is_running)); // try up to 5 port numbers before giving up -+ if (! pool.m_is_running) BAILOUT("Start of the SCP thread ppol failed: " << pool.m_listen_result.text()); - - OFVector scus(20); - OFVector scuTlsLayers; -@@ -400,7 +450,7 @@ OFTEST_FLAGS(dcmtls_scp_pool_tls, EF_Non - (*it1)->setPeerAETitle("ACCEPTOR"); - (*it1)->setAETitle("REQUESTOR"); - (*it1)->setPeerHostName("localhost"); -- (*it1)->setPeerPort(11112); -+ (*it1)->setPeerPort(port_number); - (*it1)->enableAuthentication(PRIVATE_KEY_FILENAME, PUBLIC_SELFSIGNED_CERT_FILENAME, PRIVATE_KEY_PWD, DCF_Filetype_PEM, DCF_Filetype_PEM); - (*it1)->setPeerCertVerification(DCV_ignoreCertificate); -